diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5eb2e32..6917764 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartwebdav', - version: '1.0.4', + version: '1.1.0', description: 'A TypeScript library for easy interaction with WebDAV servers, including file and directory management.' } diff --git a/ts/classes.webdavclient.ts b/ts/classes.webdavclient.ts index 420d76c..7cd0fa6 100644 --- a/ts/classes.webdavclient.ts +++ b/ts/classes.webdavclient.ts @@ -34,6 +34,18 @@ export class WebdavClient { return result as plugins.webdav.FileStat[]; } + public async getDirectoryAsSmartfileArray(pathArg: string): Promise { + const directoryListing = await this.listDirectory(pathArg); + const smartfileArray: plugins.smartfile.SmartFile[] = []; + for (const file of directoryListing) { + const fileContents = (await this.wdClient.getFileContents(file.filename, { + format: 'binary', + })) as Buffer; + smartfileArray.push(await plugins.smartfile.SmartFile.fromBuffer(file.filename, fileContents)); + } + return smartfileArray; + } + public async ensureDirectory(path: string): Promise { console.log(`Ensuring directory at ${path}`); const pathLevels = plugins.smartpath.get.pathLevels(path);