/// import { PrivilegeManagerInfo, AvailableLocksInfo, CopyInfo, CreateInfo, CreationDateInfo, DeleteInfo, DisplayNameInfo, ETagInfo, LastModifiedDateInfo, LockManagerInfo, MimeTypeInfo, MoveInfo, OpenReadStreamInfo, OpenWriteStreamInfo, PropertyManagerInfo, ReadDirInfo, RenameInfo, SizeInfo, TypeInfo } from './ContextInfo'; import { ResourceType, SimpleCallback, Return2Callback, ReturnCallback, SubTree, OpenWriteStreamMode } from './CommonTypes'; import { ISerializableFileSystem, FileSystemSerializer } from './Serialization'; import { BasicPrivilege, PrivilegeManager } from '../../../user/v2/privilege/PrivilegeManager'; import { FileSystemEvent, WebDAVServer } from '../../../server/v2/webDAVServer/WebDAVServer'; import { Readable, Writable } from 'stream'; import { IPropertyManager } from './PropertyManager'; import { ContextualFileSystem } from './ContextualFileSystem'; import { RequestContext } from '../../../server/v2/RequestContext'; import { ILockManager, ILockManagerAsync } from './LockManager'; import { LockKind } from '../../../resource/v2/lock/LockKind'; import { Resource } from './Resource'; import { Lock } from '../../../resource/v2/lock/Lock'; import { Path } from '../Path'; /** * File system which manage resources under its mounted path. * * @see https://github.com/OpenMarshal/npm-WebDAV-Server/wiki/Custom-File-System-%5Bv2%5D */ export declare abstract class FileSystem implements ISerializableFileSystem { private __serializer; constructor(serializer: FileSystemSerializer); /** * Get the serializer. */ serializer(): FileSystemSerializer; /** * Defines the serializer to use. * * @param serializer Serializer to use. */ setSerializer(serializer: FileSystemSerializer): void; /** * Tell to not serialize this file system. */ doNotSerialize(): void; /** * Wrap the file system with the context. * * @param ctx Context of the operation. */ contextualize(ctx: RequestContext): ContextualFileSystem; /** * Wrap the file system with the context and a resource path. * * @param ctx Context of the operation. * @param path Path of the resource. */ resource(ctx: RequestContext, path: Path): Resource; /** * Make a fast check if the resource exists. * If '_fastExistCheck' is not implemented, this method call 'callback'. * If '_fastExistCheck' is implemented and it returns 'false', then the 'errorCallback' is called, otherwise the 'callback' is called. * * This method will not give a true information, but just an estimate of the existence of a resource. * * @param ctx Context of the operation. * @param _path Path of the resource. * @param errorCallback Callback to call when the resource is sure to not exist. * @param callback Callback to call when the resource might exists. */ fastExistCheckEx(ctx: RequestContext, _path: Path | string, errorCallback: SimpleCallback, callback: () => void): void; /** * Make a fast check if the resource exists. * If '_fastExistCheck' is not implemented, this method call 'callback'. * If '_fastExistCheck' is implemented and it returns 'false', then the 'callback' is called, otherwise the 'errorCallback' is called. * * This method will not give a true information, but just an estimate of the existence of a resource. * * @param ctx Context of the operation. * @param _path Path of the resource. * @param errorCallback Callback to call when the resource might exists. * @param callback Callback to call when the resource is sure to not exist. */ fastExistCheckExReverse(ctx: RequestContext, _path: Path | string, errorCallback: SimpleCallback, callback: () => void): void; /** * Make a fast check if a resource exists. * This method will call '_fastExistCheck' if it is implemented or return 'true'. * * This method will not give a true information, but just an estimate of the existence of a resource. * * @param ctx Context of the operation. * @param _path Path of the resource. * @param callback Returns if the resource exists. */ protected fastExistCheck(ctx: RequestContext, _path: Path | string, callback: (exists: boolean) => void): void; protected _fastExistCheck?(ctx: RequestContext, path: Path, callback: (exists: boolean) => void): void; /** * Create a new resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param type Type of the resource to create. */ createAsync(ctx: RequestContext, path: Path | string, type: ResourceType): Promise; /** * Create a new resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param type Type of the resource to create. * @param createIntermediates Defines if the operation is allowed to create intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). */ createAsync(ctx: RequestContext, path: Path | string, type: ResourceType, createIntermediates: boolean): Promise; /** * Create a new resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param type Type of the resource to create. * @param callback Returns an error if one occured. */ create(ctx: RequestContext, path: Path | string, type: ResourceType, callback: SimpleCallback): void; /** * Create a new resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param type Type of the resource to create. * @param createIntermediates Defines if the operation is allowed to create intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param callback Returns an error if one occured. */ create(ctx: RequestContext, path: Path | string, type: ResourceType, createIntermediates: boolean, callback: SimpleCallback): void; protected _create?(path: Path, ctx: CreateInfo, callback: SimpleCallback): void; /** * Get the etag of the resource. * The default etag, if '_etag' is not implemented, is to hash the last modified date information of the resource and wrap it with quotes. * * @param ctx Context of the operation. * @param _path Path of the resource. */ etagAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the etag of the resource. * The default etag, if '_etag' is not implemented, is to hash the last modified date information of the resource and wrap it with quotes. * * @param ctx Context of the operation. * @param _path Path of the resource. * @param callback Returns the etag of the resource. */ etag(ctx: RequestContext, _path: Path | string, callback: ReturnCallback): void; protected _etag?(path: Path, ctx: ETagInfo, callback: ReturnCallback): void; /** * Delete a resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ deleteAsync(ctx: RequestContext, path: Path | string): Promise; /** * Delete a resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param depth Depth of the delete. Might be ignored depending on the implementation. */ deleteAsync(ctx: RequestContext, path: Path | string, depth: number): Promise; /** * Delete a resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns an error if one occured. */ delete(ctx: RequestContext, path: Path | string, callback: SimpleCallback): void; /** * Delete a resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param depth Depth of the delete. Might be ignored depending on the implementation. * @param callback Returns an error if one occured. */ delete(ctx: RequestContext, path: Path | string, depth: number, callback: SimpleCallback): void; protected _delete?(path: Path, ctx: DeleteInfo, callback: SimpleCallback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param estimatedSize Estimate of the size to write. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, estimatedSize: number): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, targetSource: boolean): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param estimatedSize Estimate of the size to write. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, targetSource: boolean, estimatedSize: number): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param estimatedSize Estimate of the size to write. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, estimatedSize: number): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, targetSource: boolean): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param estimatedSize Estimate of the size to write. */ openWriteStreamAsync(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, targetSource: boolean, estimatedSize: number): Promise<{ stream: Writable; created: boolean; }>; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param estimatedSize Estimate of the size to write. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, estimatedSize: number, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, targetSource: boolean, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param estimatedSize Estimate of the size to write. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, targetSource: boolean, estimatedSize: number, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param estimatedSize Estimate of the size to write. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, estimatedSize: number, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, targetSource: boolean, callback: Return2Callback): void; /** * Open a stream to write the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param mode Define if this operation can/must create a new resource and/or its intermediate resources ('/folder1/folder2/file3', if 'folder2' doesn't exist, it is an intermediate). * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param estimatedSize Estimate of the size to write. * @param callback Returns the stream. */ openWriteStream(ctx: RequestContext, path: Path | string, mode: OpenWriteStreamMode, targetSource: boolean, estimatedSize: number, callback: Return2Callback): void; protected _openWriteStream?(path: Path, ctx: OpenWriteStreamInfo, callback: ReturnCallback): void; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ openReadStreamAsync(ctx: RequestContext, path: Path | string): Promise; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param estimatedSize Estimate of the size to read. */ openReadStreamAsync(ctx: RequestContext, path: Path | string, estimatedSize: number): Promise; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. */ openReadStreamAsync(ctx: RequestContext, path: Path | string, targetSource: boolean): Promise; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param estimatedSize Estimate of the size to read. */ openReadStreamAsync(ctx: RequestContext, path: Path | string, targetSource: boolean, estimatedSize: number): Promise; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the stream. */ openReadStream(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param estimatedSize Estimate of the size to read. * @param callback Returns the stream. */ openReadStream(ctx: RequestContext, path: Path | string, estimatedSize: number, callback: ReturnCallback): void; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param callback Returns the stream. */ openReadStream(ctx: RequestContext, path: Path | string, targetSource: boolean, callback: ReturnCallback): void; /** * Open a stream to read the content of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param estimatedSize Estimate of the size to read. * @param callback Returns the stream. */ openReadStream(ctx: RequestContext, path: Path | string, targetSource: boolean, estimatedSize: number, callback: ReturnCallback): void; protected _openReadStream?(path: Path, ctx: OpenReadStreamInfo, callback: ReturnCallback): void; /** * Move a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to move. * @param pathTo Destination path to where move the resource. */ moveAsync(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string): Promise; /** * Move a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to move. * @param pathTo Destination path to where move the resource. * @param overwrite */ moveAsync(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, overwrite: boolean): Promise; /** * Move a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to move. * @param pathTo Destination path to where move the resource. * @param callback Returns if the resource has been owerwritten. */ move(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, callback: ReturnCallback): void; /** * Move a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to move. * @param pathTo Destination path to where move the resource. * @param overwrite * @param callback Returns if the resource has been owerwritten. */ move(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, overwrite: boolean, callback: ReturnCallback): void; protected _move?(pathFrom: Path, pathTo: Path, ctx: MoveInfo, callback: ReturnCallback): void; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. */ copyAsync(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string): Promise; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param depth Depth to make the copy. (Infinite = -1) */ copyAsync(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, depth: number): Promise; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param overwrite */ copyAsync(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, overwrite: boolean): Promise; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param overwrite * @param depth Depth to make the copy. (Infinite = -1) */ copyAsync(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, overwrite: boolean, depth: number): Promise; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param callback Returns if the resource has been owerwritten. */ copy(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, callback: ReturnCallback): void; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param depth Depth to make the copy. (Infinite = -1) * @param callback Returns if the resource has been owerwritten. */ copy(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, depth: number, callback: ReturnCallback): void; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param overwrite * @param callback Returns if the resource has been owerwritten. */ copy(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, overwrite: boolean, callback: ReturnCallback): void; /** * Copy a resource. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to copy. * @param pathTo Destination path to where copy the resource. * @param overwrite * @param depth Depth to make the copy. (Infinite = -1) * @param callback Returns if the resource has been owerwritten. */ copy(ctx: RequestContext, pathFrom: Path | string, pathTo: Path | string, overwrite: boolean, depth: number, callback: ReturnCallback): void; protected _copy?(pathFrom: Path, pathTo: Path, ctx: CopyInfo, callback: ReturnCallback): void; /** * Rename the resource. * By default, if the '_rename' method is not implemented, it makes a move. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to rename. * @param newName New name of the resource. */ renameAsync(ctx: RequestContext, pathFrom: Path | string, newName: string): Promise; /** * Rename the resource. * By default, if the '_rename' method is not implemented, it makes a move. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to rename. * @param newName New name of the resource. * @param overwrite */ renameAsync(ctx: RequestContext, pathFrom: Path | string, newName: string, overwrite: boolean): Promise; /** * Rename the resource. * By default, if the '_rename' method is not implemented, it makes a move. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to rename. * @param newName New name of the resource. * @param callback Returns if the resource has been owerwritten. */ rename(ctx: RequestContext, pathFrom: Path | string, newName: string, callback: ReturnCallback): void; /** * Rename the resource. * By default, if the '_rename' method is not implemented, it makes a move. * * @param ctx Context of the operation. * @param pathFrom Path of the resource to rename. * @param newName New name of the resource. * @param overwrite * @param callback Returns if the resource has been owerwritten. */ rename(ctx: RequestContext, pathFrom: Path | string, newName: string, overwrite: boolean, callback: ReturnCallback): void; protected _rename?(pathFrom: Path, newName: string, ctx: RenameInfo, callback: ReturnCallback): void; /** * Get the mime type and the encoding of the resource's content. * By default, it uses the file name of the resource to determine its mime type and its encoding. * * @param ctx Context of the operation. * @param path Path of the resource. */ mimeTypeAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the mime type and the encoding of the resource's content. * By default, it uses the file name of the resource to determine its mime type and its encoding. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. */ mimeTypeAsync(ctx: RequestContext, path: Path | string, targetSource: boolean): Promise; /** * Get the mime type and the encoding of the resource's content. * By default, it uses the file name of the resource to determine its mime type and its encoding. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the mime type and the encoding of the resource. */ mimeType(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; /** * Get the mime type and the encoding of the resource's content. * By default, it uses the file name of the resource to determine its mime type and its encoding. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param callback Returns the mime type and the encoding of the resource. */ mimeType(ctx: RequestContext, path: Path | string, targetSource: boolean, callback: ReturnCallback): void; protected _mimeType?(path: Path, ctx: MimeTypeInfo, callback: ReturnCallback): void; /** * Get the size of the resource's content. * If the '_size' method is not implemented, it returns 'undefined'. * * @param ctx Context of the operation. * @param path Path of the resource. */ sizeAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the size of the resource's content. * If the '_size' method is not implemented, it returns 'undefined'. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. */ sizeAsync(ctx: RequestContext, path: Path | string, targetSource: boolean): Promise; /** * Get the size of the resource's content. * If the '_size' method is not implemented, it returns 'undefined'. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the size of the resource. */ size(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; /** * Get the size of the resource's content. * If the '_size' method is not implemented, it returns 'undefined'. * * @param ctx Context of the operation. * @param path Path of the resource. * @param targetSource Define if the content must be the source or the computed content. Might make no difference depending on the implementation. * @param callback Returns the size of the resource. */ size(ctx: RequestContext, path: Path | string, targetSource: boolean, callback: ReturnCallback): void; protected _size?(path: Path, ctx: SizeInfo, callback: ReturnCallback): void; /** * Get the list of available lock kinds. * * @param ctx Context of the operation. * @param path Path of the resource. */ availableLocksAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the list of available lock kinds. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the list of available lock kinds. */ availableLocks(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected _availableLocks?(path: Path, ctx: AvailableLocksInfo, callback: ReturnCallback): void; /** * Get the lock manager of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ lockManagerAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the lock manager of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the lock manager of the resource. */ lockManager(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected abstract _lockManager(path: Path, ctx: LockManagerInfo, callback: ReturnCallback): void; /** * Get the property manager of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ propertyManagerAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the property manager of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the property manager of the resource. */ propertyManager(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected abstract _propertyManager(path: Path, ctx: PropertyManagerInfo, callback: ReturnCallback): void; /** * Get the list of children of a resource. * Excludes the external resources, such as file systems mounted as child. * * @param ctx Context of the operation. * @param path Path of the resource. */ readDirAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the list of children of a resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param retrieveExternalFiles Define if it must include the resources out of the file system, like other file systems mounted as child. */ readDirAsync(ctx: RequestContext, path: Path | string, retrieveExternalFiles: boolean): Promise; /** * Get the list of children of a resource. * Excludes the external resources, such as file systems mounted as child. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the list of children (file name) of the resource. */ readDir(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; /** * Get the list of children of a resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param retrieveExternalFiles Define if it must include the resources out of the file system, like other file systems mounted as child. * @param callback Returns the list of children (file name) of the resource. */ readDir(ctx: RequestContext, path: Path | string, retrieveExternalFiles: boolean, callback: ReturnCallback): void; protected _readDir?(path: Path, ctx: ReadDirInfo, callback: ReturnCallback): void; protected static neutralizeEmptyDate(date: number, defaultDate?: number): number; protected static neutralizeEmptyDateCallback: (callback: ReturnCallback) => ReturnCallback; /** * Get the creation date information of a resource. * If neither '_creationDate' nor '_lastModifiedDate' are implemented, it returns 0. * If '_creationDate' is not implemented, it calls the 'lastModifiedDate' method. * Otherwise it calls the '_creationDate' method. * * @param ctx Context of the operation. * @param path Path of the resource. */ creationDateAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the creation date information of a resource. * If neither '_creationDate' nor '_lastModifiedDate' are implemented, it returns 0. * If '_creationDate' is not implemented, it calls the 'lastModifiedDate' method. * Otherwise it calls the '_creationDate' method. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the creation date of the resource. */ creationDate(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected _creationDate?(path: Path, ctx: CreationDateInfo, callback: ReturnCallback): void; /** * Get the last modified date information of a resource. * If neither '_creationDate' nor '_lastModifiedDate' are implemented, it returns 0. * If '_lastModifiedDate' is not implemented, it calls the 'creationDate' method. * Otherwise it calls the '_lastModifiedDate' method. * * @param ctx Context of the operation. * @param path Path of the resource. */ lastModifiedDateAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the last modified date information of a resource. * If neither '_creationDate' nor '_lastModifiedDate' are implemented, it returns 0. * If '_lastModifiedDate' is not implemented, it calls the 'creationDate' method. * Otherwise it calls the '_lastModifiedDate' method. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the last modified date of the resource. */ lastModifiedDate(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected _lastModifiedDate?(path: Path, ctx: LastModifiedDateInfo, callback: ReturnCallback): void; /** * Get the name of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ webNameAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the name of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the name of the resource. */ webName(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; /** * Get the 'displayName' information of the resource. * This value is used in the 'DAV:displayName' tag in the PROPFIND response body. * Its default behaviour is to return the result of the 'webName' method. This behaviour can be overrided by implementing the '_displayName' method. * * @param ctx Context of the operation. * @param path Path of the resource. */ displayNameAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the 'displayName' information of the resource. * This value is used in the 'DAV:displayName' tag in the PROPFIND response body. * Its default behaviour is to return the result of the 'webName' method. This behaviour can be overrided by implementing the '_displayName' method. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the 'displayName' information of the resource. */ displayName(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected _displayName?(path: Path, ctx: DisplayNameInfo, callback: ReturnCallback): void; /** * Get the type of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. */ typeAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the type of the resource. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the type of the resource. */ type(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected abstract _type(path: Path, ctx: TypeInfo, callback: ReturnCallback): void; /** * Add a sub-tree to the file system at the root. * * @param ctx Context of the operation. * @param subTree Sub-tree to add. */ addSubTreeAsync(ctx: RequestContext, subTree: SubTree): Promise; /** * Add a resource to the file system as root. * * This method is equivalent to the 'fs.create(ctx, '/', resourceType, callback)' method. * * @param ctx Context of the operation. * @param resourceType Type of the resource to add. */ addSubTreeAsync(ctx: RequestContext, resourceType: ResourceType | string | Buffer): Promise; /** * Add a sub-tree to the file system. * * @param ctx Context of the operation. * @param rootPath Path to which add the sub-tree. * @param subTree Sub-tree to add. */ addSubTreeAsync(ctx: RequestContext, rootPath: Path | string, subTree: SubTree): Promise; /** * Add a resource to the file system. * * This method is equivalent to the 'fs.create(ctx, rootPath, resourceType, callback)' method. * * @param ctx Context of the operation. * @param rootPath Path to which add the resource. * @param resourceType Type of the resource to add. */ addSubTreeAsync(ctx: RequestContext, rootPath: Path | string, resourceType: ResourceType | string | Buffer): Promise; /** * Add a sub-tree to the file system at the root. * * @param ctx Context of the operation. * @param subTree Sub-tree to add. * @param callback Returns an error if one occured. */ addSubTree(ctx: RequestContext, subTree: SubTree, callback: SimpleCallback): void; /** * Add a resource to the file system as root. * * This method is equivalent to the 'fs.create(ctx, '/', resourceType, callback)' method. * * @param ctx Context of the operation. * @param resourceType Type of the resource to add. * @param callback Returns an error if one occured. */ addSubTree(ctx: RequestContext, resourceType: ResourceType | string | Buffer, callback: SimpleCallback): void; /** * Add a sub-tree to the file system. * * @param ctx Context of the operation. * @param rootPath Path to which add the sub-tree. * @param subTree Sub-tree to add. * @param callback Returns an error if one occured. */ addSubTree(ctx: RequestContext, rootPath: Path | string, subTree: SubTree, callback: SimpleCallback): void; /** * Add a resource to the file system. * * This method is equivalent to the 'fs.create(ctx, rootPath, resourceType, callback)' method. * * @param ctx Context of the operation. * @param rootPath Path to which add the resource. * @param resourceType Type of the resource to add. * @param callback Returns an error if one occured. */ addSubTree(ctx: RequestContext, rootPath: Path | string, resourceType: ResourceType | string | Buffer, callback: SimpleCallback): void; /** * Search for locks in the parents, starting at the 'startPath' path. * * @param ctx Context of the operation. * @param startPath Path where to start the research of locks. */ listDeepLocksAsync(ctx: RequestContext, startPath: Path | string): Promise<{ [path: string]: Lock[]; }>; /** * Search for locks in the parents, starting at the 'startPath' path. * * @param ctx Context of the operation. * @param startPath Path where to start the research of locks. * @param depth Depth to filter out-of-range locks (default = 0) (Infinite = -1). */ listDeepLocksAsync(ctx: RequestContext, startPath: Path | string, depth: number): Promise<{ [path: string]: Lock[]; }>; /** * Search for locks in the parents, starting at the 'startPath' path. * * @param ctx Context of the operation. * @param startPath Path where to start the research of locks. * @param callback Returns an object { path: lock[] }. */ listDeepLocks(ctx: RequestContext, startPath: Path | string, callback: ReturnCallback<{ [path: string]: Lock[]; }>): any; /** * Search for locks in the parents, starting at the 'startPath' path. * * @param ctx Context of the operation. * @param startPath Path where to start the research of locks. * @param depth Depth to filter out-of-range locks (default = 0) (Infinite = -1). * @param callback Returns an object { path: lock[] }. */ listDeepLocks(ctx: RequestContext, startPath: Path | string, depth: number, callback: ReturnCallback<{ [path: string]: Lock[]; }>): any; /** * Get the root based file system path. This can also be understood as getting the mount path of the file system. * * @param ctx Context of the operation. */ getFullPathAsync(ctx: RequestContext): Promise; /** * Get the root based path. * * @example If the file system is mounted on '/folder1', resolving '/folder2/folder3' will result to '/folder1/folder2/folder3'. * * @param ctx Context of the operation. * @param path Path to resolve. */ getFullPathAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the root based file system path. This can also be understood as getting the mount path of the file system. * * @param ctx Context of the operation. * @param callback Returns the full path (root based). */ getFullPath(ctx: RequestContext, callback: ReturnCallback): void; /** * Get the root based path. * * @example If the file system is mounted on '/folder1', resolving '/folder2/folder3' will result to '/folder1/folder2/folder3'. * * @param ctx Context of the operation. * @param path Path to resolve. * @param callback Returns the root based path. */ getFullPath(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; /** * From the global paths (root based), retrieve the file system local paths (file system based). * * @example If the file system is mounted on '/folder1', the path '/folder1/folder2/folder3' will be returned as '/folder2/folder3'. * @param ctx Context of the operation. * @param fullPath The path or the list of paths to localize in the file system. */ localizeAsync(ctx: RequestContext, fullPath: Path): Promise; localizeAsync(ctx: RequestContext, fullPath: Path[]): Promise; localizeAsync(ctx: RequestContext, fullPath: string): Promise; localizeAsync(ctx: RequestContext, fullPath: string[]): Promise; localizeAsync(ctx: RequestContext, fullPath: (string | Path)[]): Promise; /** * From the global paths (root based), retrieve the file system local paths (file system based). * * @example If the file system is mounted on '/folder1', the path '/folder1/folder2/folder3' will be returned as '/folder2/folder3'. * @param ctx Context of the operation. * @param fullPath The path or the list of paths to localize in the file system. * @param callback Returns the list of local paths. */ localize(ctx: RequestContext, fullPath: Path, callback: ReturnCallback): any; localize(ctx: RequestContext, fullPath: Path[], callback: ReturnCallback): any; localize(ctx: RequestContext, fullPath: string, callback: ReturnCallback): any; localize(ctx: RequestContext, fullPath: string[], callback: ReturnCallback): any; localize(ctx: RequestContext, fullPath: (string | Path)[], callback: ReturnCallback): any; /** * Check if the user in the current context (ctx) has ALL privileges requested. * * @param ctx Context of the operation. * @param path Path of the resource. * @param privilege Privilege or list of privileges to check. */ checkPrivilegeAsync(ctx: RequestContext, path: Path | string, privilege: BasicPrivilege): Promise; checkPrivilegeAsync(ctx: RequestContext, path: Path | string, privileges: BasicPrivilege[]): Promise; checkPrivilegeAsync(ctx: RequestContext, path: Path | string, privilege: string): Promise; checkPrivilegeAsync(ctx: RequestContext, path: Path | string, privileges: string[]): Promise; checkPrivilegeAsync(ctx: RequestContext, path: Path | string, privileges: BasicPrivilege | BasicPrivilege[]): Promise; checkPrivilegeAsync(ctx: RequestContext, path: Path | string, privileges: string | string[]): Promise; /** * Check if the user in the current context (ctx) has ALL privileges requested. * * @param ctx Context of the operation. * @param path Path of the resource. * @param privilege Privilege or list of privileges to check. * @param callback Returns if the current user has ALL of the privileges. */ checkPrivilege(ctx: RequestContext, path: Path | string, privilege: BasicPrivilege, callback: ReturnCallback): any; checkPrivilege(ctx: RequestContext, path: Path | string, privileges: BasicPrivilege[], callback: ReturnCallback): any; checkPrivilege(ctx: RequestContext, path: Path | string, privilege: string, callback: ReturnCallback): any; checkPrivilege(ctx: RequestContext, path: Path | string, privileges: string[], callback: ReturnCallback): any; checkPrivilege(ctx: RequestContext, path: Path | string, privileges: BasicPrivilege | BasicPrivilege[], callback: ReturnCallback): any; checkPrivilege(ctx: RequestContext, path: Path | string, privileges: string | string[], callback: ReturnCallback): any; /** * Get the privilege manager to use to authorize actions for a user. * By default, it returns the value in the server options, but it can be overrided by implementing the '_privilegeManager' method. * * @param ctx Context of the operation. * @param path Path of the resource. */ privilegeManagerAsync(ctx: RequestContext, path: Path | string): Promise; /** * Get the privilege manager to use to authorize actions for a user. * By default, it returns the value in the server options, but it can be overrided by implementing the '_privilegeManager' method. * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns the privilege manager representing the requested resource. */ privilegeManager(ctx: RequestContext, path: Path | string, callback: ReturnCallback): void; protected _privilegeManager?(path: Path, info: PrivilegeManagerInfo, callback: ReturnCallback): any; /** * Get if a resource is locked by another user than the one in the context argument or if the user has rights to write to the resource. * If the user has locked the resource and there is no conflicting lock, so the resource is considered as "not locked". * If the user didn't locked the resource and is not administrator, then the resource is considered as "locked". * * @param ctx Context of the operation. * @param path Path of the resource. */ isLockedAsync(ctx: RequestContext, path: Path | string): Promise; isLockedAsync(ctx: RequestContext, path: Path | string, depth: number): Promise; /** * Get if a resource is locked by another user than the one in the context argument or if the user has rights to write to the resource. * If the user has locked the resource and there is no conflicting lock, so the resource is considered as "not locked". * If the user didn't locked the resource and is not administrator, then the resource is considered as "locked". * * @param ctx Context of the operation. * @param path Path of the resource. * @param callback Returns if the resource is locked or not (true = locked, cannot write to it ; false = not locked) or returns an error. */ isLocked(ctx: RequestContext, path: Path | string, callback: ReturnCallback): any; isLocked(ctx: RequestContext, path: Path | string, depth: number, callback: ReturnCallback): any; /** * Serialize the file system based on the 'this.serializer()' value. */ serializeAsync(): Promise; /** * Serialize the file system based on the 'this.serializer()' value. * * @param callback Returns the serialized data or an error. */ serialize(callback: ReturnCallback): void; /** * Attach a listener to an event. * * @param server Server in which the event can happen. * @param event Name of the event. * @param listener Listener of the event. */ on(server: WebDAVServer, event: FileSystemEvent, listener: (ctx: RequestContext, path: Path, data?: any) => void): this; /** * Attach a listener to an event. * * @param server Server in which the event can happen. * @param event Name of the event. * @param listener Listener of the event. */ on(server: WebDAVServer, event: string, listener: (ctx: RequestContext, path: Path, data?: any) => void): this; /** * Attach a listener to an event. * * @param ctx Context containing the server in which the event can happen. * @param event Name of the event. * @param listener Listener of the event. */ on(ctx: RequestContext, event: FileSystemEvent, listener: (ctx: RequestContext, path: Path, data?: any) => void): this; /** * Attach a listener to an event. * * @param ctx Context containing the server in which the event can happen. * @param event Name of the event. * @param listener Listener of the event. */ on(ctx: RequestContext, event: string, listener: (ctx: RequestContext, path: Path, data?: any) => void): this; /** * Trigger an event. * * @param event Name of the event. * @param ctx Context of the event. * @param path Path of the resource on which the event happened. */ emit(event: string, ctx: RequestContext, path: Path | string, data?: any): void; }