File systems

EsBundleFind

const void *EsBundleFind(const EsBundle *bundle, STRING name, size_t *byteCount = ES_NULL);

Pass null as the bundle to use the current application's bundle.

EsDirectoryEnumerate

EsDirectoryChild *EsDirectoryEnumerate(STRING path, size_t *count, EsError *error = ES_NULL);

Lists the children of the directory at path. Returns an array of EsDirectoryChild; free with EsHeapFree. count receives the entry count and error receives the error.

EsFileReadAll

void *EsFileReadAll(STRING filePath, size_t *fileSize, EsError *error = ES_NULL);

Free with EsHeapFree.

EsFileReadAllFromHandle

void *EsFileReadAllFromHandle(EsHandle handle, size_t *fileSize, EsError *error = ES_NULL);

Free with EsHeapFree.

EsFileWriteAll

EsError EsFileWriteAll(STRING filePath, const void *data, size_t fileSize);

Creates the file at filePath, and any missing leading directories, and writes the data. Returns an error code.

EsFileWriteAllFromHandle

EsError EsFileWriteAllFromHandle(EsHandle handle, const void *data, size_t fileSize);

Overwrites the contents of the open file with the data. Returns an error code.

EsFileWriteAllGather

EsError EsFileWriteAllGather(STRING filePath, const void **data, const size_t *sizes, size_t gatherCount);

Creates the file at filePath and writes gatherCount buffers consecutively. Returns an error code.

EsFileWriteAllGatherFromHandle

EsError EsFileWriteAllGatherFromHandle(EsHandle handle, const void **data, const size_t *sizes, size_t gatherCount);

Overwrites the open file with gatherCount buffers written consecutively. Returns an error code.

EsFileMap

void *EsFileMap(STRING filePath, size_t *fileSize, uint32_t flags);

Maps the file at filePath into memory. Returns a pointer, or null on error. fileSize receives the file size. Unmap with EsMemoryUnreserve.

EsFileCopy

EsError EsFileCopy(STRING source, STRING destination, void **copyBuffer = ES_NULL, EsFileCopyCallback callback = ES_NULL, EsGeneric data = ES_NULL);

If you are copying lots of files, you can reuse the temporary copy buffer by storing the output copyBuffer; call EsHeapFree on it after the last copy.

EsFileControl

EsError EsFileControl(EsHandle file, EsFileControlOperation operation, void *data, size_t dataBytes);

Performs the given control operation on the open file. data is the operation payload.

EsFileOpen

EsFileInformation EsFileOpen(STRING path, EsFileOpenFlags flags);

Opens the file at path with the given flags. Returns an EsFileInformation; check its error field.

EsFileGetSize

EsFileOffset EsFileGetSize(EsHandle handle);

Returns the size of the open file.

EsFileReadSync

size_t EsFileReadSync(EsHandle file, EsFileOffset offset, size_t size, void *buffer);

Reads size bytes from file at offset into buffer. Returns the number of bytes read.

EsFileResize

EsError EsFileResize(EsHandle file, EsFileOffset newSize);

Resizes the open file to newSize. Returns an error code.

EsFileWriteSync

size_t EsFileWriteSync(EsHandle file, EsFileOffset offset, size_t size, const void *buffer);

Writes size bytes from buffer to file at offset. Returns the number of bytes written.

EsFileDelete

EsError EsFileDelete(EsHandle file);

Deletes the file. Returns an error code.

EsPathDelete

EsError EsPathDelete(STRING path);

Deletes the node at path. Returns an error code if the path does not exist.

EsPathFindUniqueName

size_t EsPathFindUniqueName(char *buffer, size_t originalBytes, size_t bufferBytes);

Modifies buffer in place to a path that does not exist yet, appending a number before the extension. Returns the new path length, or 0 on failure.

EsPathMove

EsError EsPathMove(STRING oldPath, STRING newPath, EsPathMoveFlags flags = ES_FLAGS_DEFAULT);

Moves or renames the node at oldPath to newPath. Use ES_PATH_MOVE_ALLOW_COPY_AND_DELETE to move between volumes.

EsPathExists

bool EsPathExists(STRING filePath, EsNodeType *type = ES_NULL);

Returns true if the file/directory exists.

EsPathCreate

EsError EsPathCreate(STRING filePath, EsNodeType type, bool createLeadingDirectories);

Creates a file or directory at filePath. type is ES_NODE_FILE or ES_NODE_DIRECTORY. Returns an error code if the node already exists.

EsPathQueryInformation

EsError EsPathQueryInformation(STRING filePath, EsDirectoryChild *information);

Fills information with the type, size, and content type of the node at filePath.

EsFileStoreReadAll

void *EsFileStoreReadAll(EsFileStore *file, size_t *fileSize);

Free with EsHeapFree.

EsFileStoreWriteAll

bool EsFileStoreWriteAll(EsFileStore *file, const void *data, size_t dataBytes);

Overwrites the file store's file with the data. Returns true on success.

EsFileStoreAppend

bool EsFileStoreAppend(EsFileStore *file, const void *data, size_t dataBytes);

Appends the data to the file store's file. Returns true on success.

EsFileStoreGetSize

EsFileOffsetDifference EsFileStoreGetSize(EsFileStore *file);

Returns -1 on error.

EsFileStoreMap

void *EsFileStoreMap(EsFileStore *file, size_t *fileSize, uint32_t flags);

Maps the file store's file into memory. Returns a pointer, or null on error. fileSize receives the file size.

EsFileStoreSetContentType

void EsFileStoreSetContentType(EsFileStore *file, EsUniqueIdentifier identifier);

Sets the content type of the file store's file.

EsMountPointGetVolumeInformation

bool EsMountPointGetVolumeInformation(STRING prefix, EsVolumeInformation *information);

Returns false if the mount point does not exist.

EsMountPointAdd

EsError EsMountPointAdd(STRING prefix, EsHandle base);

The system maintains a duplicate of the base handle.

EsMountPointRemove

bool EsMountPointRemove(STRING prefix);

Returns false if the mount point does not exist. You can only remove mount points you added with EsMountPointAdd.

EsOpenDocumentQueryInformation

void EsOpenDocumentQueryInformation(STRING filePath, EsOpenDocumentInformation *information);

Asks the desktop for the open document matching filePath. Fills information.

_EsPathAnnouncePathMoved

void _EsPathAnnouncePathMoved(STRING oldPath, STRING newPath);

Set oldPathBytes = 0 to make the file manager refresh the path.

_EsOpenDocumentEnumerate

void _EsOpenDocumentEnumerate(EsBuffer *outputBuffer);

Appends the list of open documents to outputBuffer. Requires the all-files permission.

EsDeviceEnumerate

EsMessageDevice *EsDeviceEnumerate(size_t *count);

This must be done with the message mutex acquired. As soon as EsMessageReceived is next called, or the message mutex is released, then the handles in this array are invalid.

EsDeviceControl

EsError EsDeviceControl(EsHandle handle, EsDeviceControlType type, void *dp, void *dq);

Sends a device control request to handle. dp and dq are the request and response data.