wxRuby Documentation Home

# Wx::FSFile

This class represents a single file opened by FileSystem.
It provides more information than Window’s input stream
(stream, filename, mime type, anchor).

Note: Any pointer returned by a method of FSFile is valid
only as long as the FSFile object exists. For example a call to GetStream()
doesn’t create the stream but only returns the pointer to it. In
other words after 10 calls to GetStream() you will obtain ten identical
pointers.

## Derived from

Object

## See Also

FileSystemHandler,
FileSystem,
Overview

## Methods

- FSFile.new
- FSFile#get_anchor
- FSFile#get_location
- FSFile#get_mime_type
- FSFile#get_modification_time
- FSFile#get_stream

### FSFile.new

FSFile.new(%(arg-type)InputStream% stream, String loc, String mimetype, String anchor, DateTime modif)

Constructor. You probably won’t use it. See Notes for details.

#### Parameters

- stream The input stream that will be used to access data
- location The full location (aka filename) of the file
- mimetype MIME type of this file. Mime type is either extension-based or HTTP Content-Type
- anchor Anchor. See get_anchor for details.

If you are not sure of the meaning of these params, see the description of the GetXXXX()
functions.

#### Notes

It is seldom used by the application programmer but you will need it if
you are writing your own virtual FS. For example you may need something
similar to MemoryInputStream, but because MemoryInputStream
doesn’t free the memory when destroyed and thus passing a memory stream
pointer into FSFile constructor would lead to memory leaks, you
can write your own class derived from FSFile:

class MyFSFile : public FSFile { private: void *m_Mem; public: MyFSFile(…..) ~MyFSFile() {free(m_Mem);} // of course dtor is virtual ;-) };

### FSFile#get_anchor

String get_anchor()

Returns anchor (if present). The term of anchor can be easily
explained using few examples:

index.htm#anchor /* ‘anchor’ is anchor */ index/wx001.htm /* NO anchor here! */ archive/main.zip#zip:index.htm#global /* ‘global’ */ archive/main.zip#zip:index.htm /* NO anchor here! */

Usually an anchor is presented only if the MIME type is ‘text/html’.
But it may have some meaning with other files;
for example myanim.avi\#200 may refer to position in animation
or reality.wrl\#MyView may refer to a predefined view in VRML.

### FSFile#get_location

String get_location()

Returns full location of the file, including path and protocol.
Examples :

http://www.wxwidgets.org http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/archive.zip#zip:info.txt file:/home/vasek/index.htm relative-file.htm

### FSFile#get_mime_type

String get_mime_type()

Returns the MIME type of the content of this file. It is either
extension-based (see MimeTypesManager) or extracted from
HTTP protocol Content-Type header.

### FSFile#get_modification_time

DateTime get_modification_time()

Returns time when this file was modified.

### FSFile#get_stream

InputStream get_stream()

Returns pointer to the stream. You can use the returned
stream to directly access data. You may suppose
that the stream provide Seek and GetSize functionality
(even in the case of the HTTP protocol which doesn’t provide
this by default. Html uses local cache to work around
this and to speed up the connection).

[This page automatically generated from the Textile source at 2023-06-09 00:45:37 +0000]