Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

File Class

Enables access to the file system.

The File class provides extensive support for file management and I/O. The class supports the notion of individual file compression and file finding capabilities. Since all File objects are tracked, there is no chance of the system leaving locked files behind after a program exits. Folder management is also integrated into this class to ease the management of both file types.

To read or write to a file, set the Path of the file as well as the correct I/O file flags before initialisation. See the Flags field for information on the available I/O flags. Functionality for read and write operations is provided through the Read() and Write() actions. The Seek() action can be used to change the read/write position in a file.

Structure

The File class consists of the following fields:

Access
NameTypeComment
 Bufferkt::vector<int8_t>Points to the internal data buffer if the file content is held in memory.

If a file has been created with an internal buffer (by setting the BUFFER flag on creation), this field will point to the address of that buffer. The size of the buffer will match the Size field.

 Createdstruct DateTimeThe creation date stamp for the file.

The Created field returns the time at which the file was first created, if supported by the filesystem. If not supported directly, the most recent 'modification date' is normally returned.

To simplify time management, information is read and set via a DateTime structure.

 Datestruct DateTimeThe 'last modified' date stamp on the file.

The Date field reflects the time at which the file was last modified. It can also be used to set a new modification date. Please note that if the file is open for writing, then date-stamped, then modified; the file system driver will overwrite the previously defined date stamp with the time at which the file was last written.

Information is read and set using a standard DateTime structure.

 FlagsFLFile flags and options.

Note: If setting flags post-initialisation, the following restrictions apply: 1. The file must not have been activated (opened) yet; 2. Only the NEW, READ and WRITE flags can be utilised.

NameDescription
FL::APPROXIMATEAllows fuzzy matching of the file path by ignoring the file extension; for instance opening 'screenshot.png' when only 'screenshot.jpg' exists in the same folder, the 'screenshot.jpg' file will be opened. If multiple files could potentially match to the file name, the file object will select the first match that is encountered.
FL::BUFFERActivates a special mode in which the file data is stored in a memory buffer rather than a disk file. Set the Size field to a value of at least 1 so that the initial buffer size is configured. In this mode many of the available file operations are meaningless except for the Read, Write and Seek actions.
FL::DEVICEThe file is a system device (must set if opening a device for read/write operations)
FL::DIRECTORYThe file object represents a folder.
FL::EXCLUDE_FILESExclude files when scanning this folder.
FL::EXCLUDE_FOLDERSExclude folders when scanning this folder.
FL::FILEExplicitly declares the file object as an entity that stores content (as opposed to a device or folder for example).
FL::FOLDERThe file object represents a folder.
FL::LINKRead-Only. Indicates that the file is a symbolic link or shortcut to another file.
FL::LOOPIn loop mode, the file object's position marker for read/write operations is allowed to extend past the actual file size. Any read/write operation beyond the file size will loop back to the file at a corrected offset - for example, reading position 330 of a 100 byte file will start the operation from the 30th byte. Loop mode does not affect any other area besides the read, write and seek operations. The loop feature is typically used to create multimedia data streams with minimal effort.
FL::NEWRequired when creating a new file. If a file with the same name exists, its contents will be destroyed. If however the existing file is locked, the initalisation process will fail.
FL::READRequired if the file needs to be opened for read access.
FL::RESET_DATEFor internal use only
FL::STREAMFile data is streamed (e.g. PIPE, FIFO, socket) and may be accessed locally or via a network.
FL::VIRTUALPath is to a virtual device.
FL::WRITEPrepares a file for writing data, starting at byte position 0. To start writing from the end of a file, use the Seek action after the file has been initialised.
 GroupINTRetrieve or change the group ID of a file.

The group ID assigned to a file can be read from this field. The ID is retrieved from the file system in real time in case the ID has been changed after initialisation of the file object.

You can also change the group ID of a file by writing an integer value to this field.

If the file system does not support group ID's, ERR::NoSupport is returned.

 HandleINT64The native system handle for the file opened by the file object.

This field returns the native file system handle for the file opened by the file object. The native handle may be an integer or pointer value in 32 or 64-bit format. In order to manage this issue in a multi-platform manner, the value is returned as a 64-bit integer.

 IconSTRINGReturns an icon reference that is suitable for this file in the UI.

This field returns the name of the best icon to use when representing the file to the user, for instance in a file list. The icon style is determined by analysing the File's Path.

The resulting string is returned in the format icons:category/name and will refer to an SVG file.

 LinkSTRINGReturns the link path for symbolically linked files.

If a file represents a symbolic link (indicated by the SYMLINK flag setting) then reading the Link field will return the link path. No assurance is made as to the validity of the path. If the path is not absolute, then the parent folder containing the link will need to be taken into consideration when calculating the path that the link refers to.

 PathSTRINGSpecifies the location of a file or folder.

This field is required for initialisation and must either be in the format of a universal path string, or a path that is compatible with the host system. The standard format for a universal path is volume:folder/file, for instance kotuku:system/classes.bin.

To reference a folder in a way that is distinct from a file, use a trailing slash as in volume:folder/.

Referencing a volume: is optional. In the event that a volume is not defined, the current working path is used as the point of origin.

The accepted method for referencing parent folders is ../, which can be repeated for as many parent folders as needed to traverse the folder hierarchy.

Access to std* handles is achieved by using the path strings std:in, std:out and std:err.

 PermissionsPERMITManages the permissions of a file.
NameDescription
PERMIT::ALL_DELETESynonym for EVERYONE_DELETE
PERMIT::ALL_EXECSynonym for EVERYONE_EXEC
PERMIT::ALL_READSynonym for EVERYONE_READ
PERMIT::ALL_WRITESynonym for EVERYONE_WRITE
PERMIT::ARCHIVEMarks the file for future backup. The flag should be cleared after the backup has succeeded
PERMIT::DELETEOwner can delete. If the file system does not support this, deletion is enabled via the WRITE flag
PERMIT::EVERYONE_ACCESSSynonym for EVERYONE_READ | EVERYONE_WRITE | EVERYONE_EXEC | EVERYONE_DELETE
PERMIT::EVERYONE_DELETESynonym for DELETE | GROUP_DELETE | OTHERS_DELETE
PERMIT::EVERYONE_EXECSynonym for EXEC | GROUP_EXEC | OTHERS_EXEC
PERMIT::EVERYONE_READSynonym for READ | GROUP_READ | OTHERS_READ
PERMIT::EVERYONE_READWRITESynonym for EVERYONE_READ | EVERYONE_WRITE
PERMIT::EVERYONE_WRITESynonym for WRITE | GROUP_WRITE | OTHERS_WRITE
PERMIT::EXECUser/Owner can execute
PERMIT::GROUPSynonym for GROUP_READ | GROUP_WRITE | GROUP_EXEC | GROUP_DELETE
PERMIT::GROUPIDAllows executables to run with a set group id
PERMIT::GROUP_DELETEGroup members can delete
PERMIT::GROUP_EXECGroup members can execute
PERMIT::GROUP_READGroup members can read
PERMIT::GROUP_WRITEGroup members can write
PERMIT::HIDDENRecommends that the file is hidden from view by default
PERMIT::INHERITInherit permissions from parent folder and logical OR them with preset permission flags
PERMIT::METASynonym for HIDDEN | PASSWORD | OFFLINE | NETWORK
PERMIT::NETWORKFile is hosted on another machine
PERMIT::OFFLINEFile content for this networked file has not been cached on the local PC
PERMIT::OTHERSSynonym for OTHERS_READ | OTHERS_WRITE | OTHERS_EXEC | OTHERS_DELETE
PERMIT::OTHERS_DELETEOthers can delete
PERMIT::OTHERS_EXECOthers can execute
PERMIT::OTHERS_READOthers can read
PERMIT::OTHERS_WRITEOthers can write
PERMIT::PASSWORDFile is password protected
PERMIT::READUser/Owner has read access. This will not allow compiled code to be executed
PERMIT::USERSynonym for READ | WRITE | EXEC | DELETE
PERMIT::USERIDAllows executables to run with a set user id
PERMIT::USER_EXECSynonym for EXEC
PERMIT::USER_READSynonym for READ
PERMIT::USER_WRITESynonym for WRITE
PERMIT::WRITEUser/Owner can write
 PositionINT64The current read/write byte position in a file.

This field indicates the current byte position of an open file (this affects read and write operations). Writing to this field performs a Seek() operation.

The Position will always remain at zero if the file object represents a folder.

 ResolvedPathSTRINGReturns a resolved copy of the Path string.

The ResolvedPath will return a resolved copy of the Path string. The resolved path will be in a format that is native to the host platform. Please refer to the ResolvePath() function for further information.

 SizeINT64The byte size of a file.

The current byte size of a file is indicated by this field. If the file object represents a folder, the Size value will be zero. You can also truncate a file by setting the Size; this will result in the current read/write position being set to the end of the file.

 TimestampINT64The last modification time set on a file, represented as a 64-bit integer.

The Timestamp field is a 64-bit representation of the last modification date/time set on a file. It is not guaranteed that the value represents seconds from the epoch, so it should only be used for purposes such as sorting, or for comparison to the time stamps of other files. For a parsed time structure, refer to the Date field.

 UserINTRetrieve or change the user ID of a file.

The user ID assigned to a file can be read from this field. The ID is retrieved from the file system in real time in case the ID has been changed after initialisation of the file object.

You can also change the user ID of a file by writing an integer value to this field. This can only be done post-initialisation or an error code will be returned.

If the filesystem does not support user ID's, ERR::NoSupport is returned.

Actions

The following actions are currently supported:

ActivateOpens the file. Performed automatically if NEW, READ or WRITE flags were specified on initialisation.
DataFeedData can be streamed to any file as a method of writing content.
ERR acDataFeed(*Object, OBJECTID Object, DATA Datatype, std::span<const int8_t> Buffer)
ParameterDescription
ObjectMust refer to the unique ID of the object that you represent. If you do not represent an object, set this parameter to the current task ID.
DatatypeThe type of data being sent.
BufferThe data being sent to the target object.

Streaming data of any type to a file will result in the content being written to the file at the current seek Position.

FlushFlushes all pending write operations.
InitInitialises a file.
ERR InitObject(*Object)

This action will prepare a file or folder at the given Path for use.

To create a new file from scratch, specify the NEW flag. This will overwrite any file that exists at the target path.

To read and write data to the file, specify the READ and/or WRITE modes in the Flags field prior to initialisation. If a file is read-only and the WRITE and READ flags are set in combination, the WRITE flag will be dropped and initialisation will continue as normal.

If neither of the NEW, READ or WRITE flags are specified, the file object is prepared and queried from disk (if it exists), but will not be opened. It will be necessary to Activate() the file in order to open it.

The File class supports RAM based file buffering - this is activated by using the BUFFER flag and setting the Size field to the desired buffer size. A file path is not required unless the buffer needs to be filled with content on initialisation. Because buffered files exist virtually, their functionality is restricted to read/write access.

Strings can also be loaded into file buffers for read/write access. This is achieved by specifying the Path string:Data\0, where Data is a sequence of characters to be loaded into a virtual memory space.

Error Codes
OkayOperation successful.
FileFile error, e.g. file not found
SearchThe file could not be found.
FileNotFoundFile not found
NoPermissionPermission was denied when accessing or creating the file.
InvalidPathInvalid file or folder path detected
SetFieldAn error occurred while updating the Path field.
MissingPathThe object is missing a path reference
VirtualVolumeResolvePath() failed to resolve the path because it is a virtual reference
ResolvePathA call to ResolvePath() failed
ExpectedFileThe operation expected a path to a file
CreateFileA new file could not be created
UseDerivedRequested to use a registered derived class (not an error)
QueryRead a file's meta information from source.
ReadReads data from a file.
ERR acRead(*Object, std::span<int8_t> Buffer, INT *Result)
ParameterDescription
BufferA mutable buffer that will receive the data.
ResultThe Read action will write this parameter with the total number of bytes read into the Buffer.

Reads data from a file into the given buffer. Increases the value in the Position field by the amount of bytes read from the file data. The FL::READ bit in the Flags field must have been set on file initialisation, or the call will fail.

It is normal behaviour for this call to report success in the event that no data has been read from the file, e.g. if the end of the file has been reached. The Result parameter will be returned as zero in such cases. Check the current Position against the Size to confirm that the end has been reached.

Error Codes
OkayThe file information was read into the buffer.
FailedThe file object refers to a folder, or the object is corrupt.
ArgsInvalid arguments passed to function
OutOfRangeInvalid Length parameter.
FileReadFlagThe FL::READ flag was not specified on initialisation.
NotInitialisedThe resource has not been initialised
SystemCallA call to the host system has failed
ExpectedFileThe operation expected a path to a file
NullArgsFunction call missing argument value(s)
ExpectedFolderThe file object refers to a folder.
RenameChanges the name of a file.
ERR acRename(*Object, std::string_view Name)
ParameterDescription
NameThe new name for the object.
ResetIf the file represents a folder, the file list index is reset by this action.
SeekSeeks to a new read/write position within a file.
ERR acSeek(*Object, DOUBLE Offset, INT Position)
ParameterDescription
OffsetThe desired offset to seek to, relative to the Position parameter.
PositionThe position that defines the starting point for Offset.
WriteWrites data to a file.
ERR acWrite(*Object, std::span<const int8_t> Buffer, INT *Result)
ParameterDescription
BufferA buffer containing the data that will be written to the object.
ResultThis parameter with be updated with the total number of bytes written from the Buffer.

Writes data from the provided buffer into the file, then updates the Position field to reflect the new read/write position. You must have set the FL::WRITE bit in the Flags field when you initialised the file, or the call will fail.

Error Codes
OkayAll of the data was written to the file.
LimitedSuccessOnly some of the data was written to the file. Check the Result parameter to see how much data was written.
ArgsInvalid arguments passed to function
FileWriteFlagThe FL::WRITE flag was not specified when initialising the file.
ObjectCorruptThe object structure is corrupt or has not been initialised
ExpectedFileThe operation expected a path to a file
NullArgsFunction call missing argument value(s)

Methods

The following methods are currently supported:

BufferContentReads all file content into a local memory buffer.
ERR fl::BufferContent(OBJECTPTR Object)

File content may be buffered at any time by calling the BufferContent method. This will allocate a buffer that matches the current file size and the file's content will be read into that buffer. The BUFFER flag is set in the file object and a pointer to the content is referenced in the file's Buffer field. Standard file operations such as read, write and seek have the same effect when a file is in buffer mode.

Once a file has been buffered, the original file handle and any locks on that file are returned to the system. Physical operations on the file object such as delete, rename and attribute settings no longer have meaning when applied to a buffered file. It is not possible to drop the buffer and return the file object to its original state once buffering has been enabled.

Error Codes
OkayThe file content was successfully buffered.
NothingDoneThe file is already buffered.
ReadError reading data
InvalidStateThe targeted file is not open for read operations.
CopyCopies the data of a file to another location.
ERR fl::Copy(OBJECTPTR Object, STRVIEW Dest, FUNCTION Callback)
ParameterDescription
DestThe destination file path for the copy operation.
CallbackOptional callback for receiving feedback during the operation.

This method is used to copy the data of a file object to another location. All of the data will be copied, effectively creating a clone of the original file information. The file object must have been initialised with the FL::READ flag, or the copy operation will not work (this restriction does not apply to directories). If a matching file name already exists at the destination path, it will be over-written with the new data.

The Position field will be reset as a result of calling this method.

When copying directories with this method, the entire folder structure (i.e. all of the folder contents) will be copied to the new location. If an error occurs when copying a sub-folder or file, the procedure will be aborted and an error code will be returned.

Error Codes
OkayThe file data was copied successfully.
FailedGeneral failure
ArgsInvalid arguments passed to function
ReadData could not be read from the source path.
WriteData could not be written to the destination path.
FieldNotSetThe Path field has not been set in the file object.
LoopPerforming the copy would cause infinite recursion.
ResolvePathA call to ResolvePath() failed
NullArgsFunction call missing argument value(s)
DeleteDeletes a file from its source location.
ERR fl::Delete(OBJECTPTR Object, FUNCTION Callback)
ParameterDescription
CallbackOptional callback for receiving feedback during the operation.

This method is used to delete files from their source location. If used on a folder, all of the folder's contents will be deleted in the call. Once a file is deleted, the object effectively becomes unusable. For this reason, file deletion should normally be followed up with a call to the Free action.

Error Codes
OkayFile deleted successfully.
CancelledOperation cancelled
FailedThe deletion attempt failed (specific condition not available).
NoPermissionThe user does not have the necessary permissions to delete the file.
MissingPathThe object is missing a path reference
BufferOverflowThe file path string is too long.
ResolvePathA call to ResolvePath() failed
SystemCallA call to the host system has failed
DeleteFileDeletion of a folder or file failed (e.g. permissions, read-only media)
ReadOnlyThe file is on a read-only filesystem.
LockedThe file is in use.
MoveMoves a file to a new location.
ERR fl::Move(OBJECTPTR Object, STRVIEW Dest, FUNCTION Callback)
ParameterDescription
DestThe desired path for the file.
CallbackOptional callback for receiving feedback during the operation.

This method is used to move the data of a file to another location. If the file object represents a folder, then the folder and all of its contents will be moved. The file object must have been initialised with the FL::READ flag, or the move operation will not work (this restriction does not apply to directories). If a file already exists at the destination path then it will be over-written with the new data.

The Position field will be reset as a result of calling this method.

Error Codes
OkayThe File was moved successfully.
ArgsInvalid arguments passed to function
InvalidPathAttempted to move a volume.
FieldNotSetThe Path field has not been set in the file object.
NullArgsFunction call missing argument value(s)
NextRetrieve meta information describing the next indexed file in the folder list.
ERR fl::Next(OBJECTPTR Object, objFile ** File)
ParameterDescription
FileA pointer to a new File object will be returned in this parameter if the call is successful.

If a file object represents a folder, calling the Next() method will retrieve meta information about the next file in the folder's index. This information will be returned as a new File object that is partially initialised (the file will not be opened, but information such as size, timestamps and permissions will be retrievable).

If desired, the resulting file object can be opened by setting the READ or WRITE bits in Flags and then calling the Activate() action.

It is the responsibility of the caller to free the resulting File object once it is no longer required.

The file index can be reset by calling the Reset() action.

Error Codes
OkayOperation successful.
EndOfSequenceThe index has reached the end of the file list.
ArgsInvalid arguments passed to function
CreateObjectA call to CreateObject() failed
NullArgsFunction call missing argument value(s)
ExpectedFolderThe operation expected a folder path
ReadLineReads the next line from the file.
ERR fl::ReadLine(OBJECTPTR Object, STRING * Result)
ParameterDescription
ResultThe string provided in this parameter will be updated with the line read from the file.

Reads one line from the file into a provided string buffer, which is required in the Result argument. Reading a line will increase the Position field by the amount of bytes read from the file. You must have set the FL::READ bit in the Flags field when you initialised the file, or the call will fail.

ERR::NoData is returned once all lines have been read.

Error Codes
OkayThe file information was read into the buffer.
FailedThe file object refers to a folder.
ArgsInvalid arguments passed to function
NoDataThere is no more data left to read.
FileReadFlagThe FL::READ flag was not specified on initialisation.
ObjectCorruptThe internal file handle is missing.
BufferOverflowThe line is too long for the read routine (4096 byte limit).
ExpectedFileThe operation expected a path to a file
NullArgsFunction call missing argument value(s)
SetDateSets the date on a file.
ERR fl::SetDate(OBJECTPTR Object, INT Year, INT Month, INT Day, INT Hour, INT Minute, INT Second, FDT Type)
ParameterDescription
YearYear (-ve for BC, +ve for AD).
MonthMonth (1 - 12)
DayDay (1 - 31)
HourHour (0 - 23
MinuteMinute (0 - 59)
SecondSecond (0 - 59)
TypeThe type of date to set (filesystem dependent).

The SetDate method provides a convenient way to set the date and time information for a file object. Date information is set in a human readable year, month, day, hour, minute and second format for your convenience.

Depending on the filesystem type, multiple forms of datestamp may be supported. The default datestamp, FDT::MODIFIED defines the time at which the file data was last altered. Other types include the date on which the file was created and the date it was last archived (backed up). The following types are supported by the Type argument:

NameDescription
FDT::ACCESSEDThe date on which the file was last accessed by a user or application.
FDT::ARCHIVEDThe date on which the file was most recently archived. Not supported by most filesystems.
FDT::CREATEDThe date on which the file was created. On some host platforms this datestamp may be read-only.
FDT::MODIFIEDThe date on which the file was last modified.

If the specified datestamp is not supported by the filesystem, ERR::NoSupport is returned by this method.

Error Codes
OkayOperation successful.
NoSupportThe platform does not support file date setting.
ResolvePathA call to ResolvePath() failed
SystemCallA call to the host system has failed
NullArgsFunction call missing argument value(s)
StartStreamStarts streaming data from a file source.
ERR fl::StartStream(OBJECTPTR Object, OBJECTID Subscriber, FL Flags, INT Length)
ParameterDescription
SubscriberReference to an object that will receive streamed data notifications.
FlagsUse READ for incoming data, WRITE for outgoing data.
LengthLimits the total amount of data to be streamed.

If a file object is a stream (indicated by the STREAM flag), the StartStream method should be used for reading or writing data to the file object. Although it is possible to call the Read and Write actions on streamed files, they will be limited to returning only the amount of data that is cached locally (if any), or writing as much as buffers will allow in software.

A single file object can support read or write streams (pass FL::READ or FL::WRITE in the Flags parameter). However, only one of the two can be active at any time. To switch between read and write modes, the stream must be stopped with the StopStream() method and then restarted with StartStream.

A stream can be limited by setting the Length parameter to a non-zero value.

If the StartStream request is successful, the file object will return action notifications to the Subscriber to indicate activity on the file stream. When reading from a stream, AC::Write notifications will be received to indicate that new data has been written to the file cache. The Buffer parameter of the reported acWrite structure may refer to a private address that contains the data that was received from the stream and the Result indicates the amount of new data available.

When writing to a stream, AC::Read notifications will be received to indicate that the stream is ready to accept more data. The Result parameter will indicate the maximum amount of data that should be written to the stream using the Write() action.

A stream can be cancelled at any time by calling StopStream().

Error Codes
OkayOperation successful.
ArgsInvalid arguments passed to function
NoSupportThe file is not streamed.
NullArgsFunction call missing argument value(s)
StopStreamStops streaming data from a file source.
ERR fl::StopStream(OBJECTPTR Object)

This method terminates data streaming from a file (instantiated by the StartStream() method). Any resources related to the streaming process will be deallocated.

Error Codes
OkayOperation successful.
ArgsInvalid arguments passed to function
NoSupportThe file is not streamed.
WatchMonitors files and folders for file system events.
ERR fl::Watch(OBJECTPTR Object, FUNCTION Callback, MFF Flags)
ParameterDescription
CallbackThe routine that will be called when a file change is triggered by the system.
FlagsFilter events to those indicated in these flags.

The Watch() method configures event based reporting for changes to any file or folder in the file system. The capabilities of this method are dependent on the host platform, with Windows and Linux systems being able to support most of the current feature set.

The path that will be monitored is determined by the File object's Path field. Both files and folders are supported as targets.

The optional MFF Flags are used to filter events to those that are desired for monitoring.

The client must provide a Callback that will be triggered when a monitored event is triggered. The Callback must follow the format ERR Routine(*File, std::string_view Path, MFF Flags, APTR Meta)

Each event will be delivered in the sequence that they are originally raised. The Flags parameter will reflect the specific event that has occurred. The Path is a string that is relative to the File's Path field.

If the callback routine returns ERR::Terminate, the watch will be disabled. It is also possible to disable an existing watch by calling this method with no parameters, or by setting the Flags parameter to MFF::NIL.

Error Codes
OkayOperation successful.
ArgsInvalid arguments passed to function
NoSupportOperation not supported
AllocMemoryFailed to create a new memory block
NullArgsFunction call missing argument value(s)
File class documentation © Paul Manias © 1996-2026

FDT Type

Flags for the SetDate() file method.

NameDescription
FDT::ACCESSEDThe date on which the file was last accessed by a user or application.
FDT::ARCHIVEDThe date on which the file was most recently archived. Not supported by most filesystems.
FDT::CREATEDThe date on which the file was created. On some host platforms this datestamp may be read-only.
FDT::MODIFIEDThe date on which the file was last modified.
File module documentation © Paul Manias © 1996-2026

FL Type

File flags

NameDescription
FL::APPROXIMATEAllows fuzzy matching of the file path by ignoring the file extension; for instance opening 'screenshot.png' when only 'screenshot.jpg' exists in the same folder, the 'screenshot.jpg' file will be opened. If multiple files could potentially match to the file name, the file object will select the first match that is encountered.
FL::BUFFERActivates a special mode in which the file data is stored in a memory buffer rather than a disk file. Set the Size field to a value of at least 1 so that the initial buffer size is configured. In this mode many of the available file operations are meaningless except for the Read, Write and Seek actions.
FL::DEVICEThe file is a system device (must set if opening a device for read/write operations)
FL::DIRECTORYThe file object represents a folder.
FL::EXCLUDE_FILESExclude files when scanning this folder.
FL::EXCLUDE_FOLDERSExclude folders when scanning this folder.
FL::FILEExplicitly declares the file object as an entity that stores content (as opposed to a device or folder for example).
FL::FOLDERThe file object represents a folder.
FL::LINKRead-Only. Indicates that the file is a symbolic link or shortcut to another file.
FL::LOOPIn loop mode, the file object's position marker for read/write operations is allowed to extend past the actual file size. Any read/write operation beyond the file size will loop back to the file at a corrected offset - for example, reading position 330 of a 100 byte file will start the operation from the 30th byte. Loop mode does not affect any other area besides the read, write and seek operations. The loop feature is typically used to create multimedia data streams with minimal effort.
FL::NEWRequired when creating a new file. If a file with the same name exists, its contents will be destroyed. If however the existing file is locked, the initalisation process will fail.
FL::READRequired if the file needs to be opened for read access.
FL::RESET_DATEFor internal use only
FL::STREAMFile data is streamed (e.g. PIPE, FIFO, socket) and may be accessed locally or via a network.
FL::VIRTUALPath is to a virtual device.
FL::WRITEPrepares a file for writing data, starting at byte position 0. To start writing from the end of a file, use the Seek action after the file has been initialised.
File module documentation © Paul Manias © 1996-2026

MFF Type

Flags for the File Watch() method.

NameDescription
MFF::ATTRIBFile permissions or datestamp changed.
MFF::CLOSEDAn opened file has been closed.
MFF::CREATENew file/link created or renamed in folder.
MFF::DEEPReceive notifications from sub-folders (Windows only).
MFF::DELETEExisting file deleted
MFF::FILEFile identifier; if passed to File⇒Watch() then indicates a preference for file events only.
MFF::FOLDERFolder identifier; if passed to File⇒Watch() then indicates a preference for folder events only.
MFF::MODIFYFile modified via write or truncation.
MFF::MOVEDExisting file moved or renamed.
MFF::OPENEDExisting file was opened.
MFF::READFile was accessed (read).
MFF::RENAMEExisting file moved or renamed.
MFF::SELFEvent applies to the monitored folder and not a contained item
MFF::UNMOUNTHost filesystem was unmounted.
MFF::WRITEFile modified via write or truncation.
File module documentation © Paul Manias © 1996-2026

PERMIT Type

Permission flags

NameDescription
PERMIT::ALL_DELETESynonym for EVERYONE_DELETE
PERMIT::ALL_EXECSynonym for EVERYONE_EXEC
PERMIT::ALL_READSynonym for EVERYONE_READ
PERMIT::ALL_WRITESynonym for EVERYONE_WRITE
PERMIT::ARCHIVEMarks the file for future backup. The flag should be cleared after the backup has succeeded
PERMIT::DELETEOwner can delete. If the file system does not support this, deletion is enabled via the WRITE flag
PERMIT::EVERYONE_ACCESSSynonym for EVERYONE_READ | EVERYONE_WRITE | EVERYONE_EXEC | EVERYONE_DELETE
PERMIT::EVERYONE_DELETESynonym for DELETE | GROUP_DELETE | OTHERS_DELETE
PERMIT::EVERYONE_EXECSynonym for EXEC | GROUP_EXEC | OTHERS_EXEC
PERMIT::EVERYONE_READSynonym for READ | GROUP_READ | OTHERS_READ
PERMIT::EVERYONE_READWRITESynonym for EVERYONE_READ | EVERYONE_WRITE
PERMIT::EVERYONE_WRITESynonym for WRITE | GROUP_WRITE | OTHERS_WRITE
PERMIT::EXECUser/Owner can execute
PERMIT::GROUPSynonym for GROUP_READ | GROUP_WRITE | GROUP_EXEC | GROUP_DELETE
PERMIT::GROUPIDAllows executables to run with a set group id
PERMIT::GROUP_DELETEGroup members can delete
PERMIT::GROUP_EXECGroup members can execute
PERMIT::GROUP_READGroup members can read
PERMIT::GROUP_WRITEGroup members can write
PERMIT::HIDDENRecommends that the file is hidden from view by default
PERMIT::INHERITInherit permissions from parent folder and logical OR them with preset permission flags
PERMIT::METASynonym for HIDDEN | PASSWORD | OFFLINE | NETWORK
PERMIT::NETWORKFile is hosted on another machine
PERMIT::OFFLINEFile content for this networked file has not been cached on the local PC
PERMIT::OTHERSSynonym for OTHERS_READ | OTHERS_WRITE | OTHERS_EXEC | OTHERS_DELETE
PERMIT::OTHERS_DELETEOthers can delete
PERMIT::OTHERS_EXECOthers can execute
PERMIT::OTHERS_READOthers can read
PERMIT::OTHERS_WRITEOthers can write
PERMIT::PASSWORDFile is password protected
PERMIT::READUser/Owner has read access. This will not allow compiled code to be executed
PERMIT::USERSynonym for READ | WRITE | EXEC | DELETE
PERMIT::USERIDAllows executables to run with a set user id
PERMIT::USER_EXECSynonym for EXEC
PERMIT::USER_READSynonym for READ
PERMIT::USER_WRITESynonym for WRITE
PERMIT::WRITEUser/Owner can write
File module documentation © Paul Manias © 1996-2026