Files
NativeScript/nativescript-core/file-system/file-system-access.d.ts
Alexander Vakrilov cc97a16800 feat: Scoped Packages (#7911)
* chore: move tns-core-modules to nativescript-core

* chore: preparing compat generate script

* chore: add missing definitions

* chore: no need for http-request to be private

* chore: packages chore

* test: generate tests for tns-core-modules

* chore: add anroid module for consistency

* chore: add .npmignore

* chore: added privateModulesWhitelist

* chore(webpack): added bundle-entry-points

* chore: scripts

* chore: tests changed to use @ns/core

* test: add scoped-packages test project

* test: fix types

* test: update test project

* chore: build scripts

* chore: update build script

* chore: npm scripts cleanup

* chore: make the compat pgk work with old wp config

* test: generate diff friendly tests

* chore: create barrel exports

* chore: move files after rebase

* chore: typedoc config

* chore: compat mode

* chore: review of barrels

* chore: remove tns-core-modules import after rebase

* chore: dev workflow setup

* chore: update developer-workflow

* docs: experiment with API extractor

* chore: api-extractor and barrel exports

* chore: api-extractor configs

* chore: generate d.ts rollup with api-extractor

* refactor: move methods inside Frame

* chore: fic tests to use Frame static methods

* refactor: create Builder class

* refactor: use Builder class in tests

* refactor: include Style in ui barrel

* chore: separate compat build script

* chore: fix tslint errors

* chore: update NATIVESCRIPT_CORE_ARGS

* chore: fix compat pack

* chore: fix ui-test-app build with linked modules

* chore: Application, ApplicationSettings, Connectivity and Http

* chore: export Trace, Profiling and Utils

* refactor: Static create methods for ImageSource

* chore: fix deprecated usages of ImageSource

* chore: move Span and FormattedString to ui

* chore: add events-args and ImageSource to index files

* chore: check for CLI >= 6.2 when building for IOS

* chore: update travis build

* chore: copy Pod file to compat package

* chore: update error msg ui-tests-app

* refactor: Apply suggestions from code review

Co-Authored-By: Martin Yankov <m.i.yankov@gmail.com>

* chore: typings and refs

* chore: add missing d.ts files for public API

* chore: adress code review FB

* chore: update api-report

* chore: dev-workflow for other apps

* chore: api update

* chore: update api-report
2019-10-17 00:45:33 +03:00

255 lines
9.5 KiB
TypeScript

/**
* @module "file-system/file-system-access"
*/ /** */
/**
* An utility class used to provide methods to access and work with the file system.
*/
export class FileSystemAccess {
/**
* Gets the last modified date of a file with a given path.
* @param path Path to the file.
*/
getLastModified(path: string): Date;
/**
* Gets the size in bytes of a file with a given path.
* @param path Path to the file.
*/
getFileSize(path: string): number;
/**
* Gets the parent folder of a file with a given path.
* @param path Path to the file.
* @param onError A callback function to use if any error occurs.
* Returns path Absolute path of the parent folder, name Name of the parent folder.
*/
getParent(path: string, onError?: (error: any) => any): { path: string; name: string };
/**
* Gets a file from a given path.
* @param path Path to the file.
* @param onError A callback function to use if any error occurs.
* Returns path Absolute path of the file, name Name of the file, extension Extension of the file.
*/
getFile(path: string, onError?: (error: any) => any): { path: string; name: string; extension: string };
/**
* Gets the folder of a file with a given path.
* @param path Path to the file.
* @param onError A callback function to use if any error occurs.
* Returns path Absolute path of the folder, name Name of the folder.
*/
getFolder(path: string, onError?: (error: any) => any): { path: string; name: string };
/**
* Gets all entities of a given path (folder)
* @param path Path to the file.
* @param onError (optional) A callback function to use if any error occurs.
* Returns an array of entities in the folder.
*/
getEntities(path: string, onError?: (error: any) => any): Array<{ path: string; name: string; extension: string }>;
/**
* Performs an action onSuccess for every entity in a folder with a given path.
* Breaks the loop if onSuccess function returns false
* @param path Path to the file.
* @param onEntity A callback function which is called for each entity.
* @param onError (optional) A callback function to use if any error occurs.
*/
eachEntity(path: string, onEntity: (entity: { path: string; name: string; extension: string }) => boolean, onError?: (error: any) => any);
/**
* Checks if a file with a given path exist.
*/
fileExists(path: string): boolean;
/**
* Checks if a folder with a given path exist.
*/
folderExists(path: string): boolean;
/**
* Deletes a file with a given path.
* @param path Path of the file.
* @param onError (optional) A callback function to use if any error occurs.
*/
deleteFile(path: string, onError?: (error: any) => any);
/**
* Deletes a folder with a given path.
* @param path Path of the folder.
* @param onError (optional) A callback function to use if any error occurs.
*/
deleteFolder(path: string, onError?: (error: any) => any);
/**
* Deletes all content of a folder with a given path.
* @param path Path of the folder.
* @param onError (optional) A callback function to use if any error occurs.
*/
emptyFolder(path: string, onError?: (error: any) => any): void;
/**
* Rename a file or a folder with a given path.
* @param path Current path of the entity which should be renamed.
* @param newPath The new path which will be asigned of the entity.
* @param onError (optional) A callback function to use if any error occurs.
*/
rename(path: string, newPath: string, onError?: (error: any) => any): void;
/**
* Gets the special documents folder.
* Returns for Android: "/data/data/applicationPackageName/files", iOS: "/var/mobile/Applications/appID/Documents"
*/
getDocumentsFolderPath(): string;
/**
* Gets the special temp folder.
* Returns for Android: "/data/data/applicationPackageName/cache", iOS: "/var/mobile/Applications/appID/Library/Caches"
*/
getTempFolderPath(): string;
/**
* Gets the path to the logical root of the application - that is /path/to/appfiles/app.
*/
getLogicalRootPath(): string;
/**
* Gets the root folder for the current application. This Folder is private for the application and not accessible from Users/External apps.
* iOS - this folder is read-only and contains the app and all its resources.
*/
getCurrentAppPath(): string;
/**
* Reads a text from a file with a given path.
* @param path The path to the source file.
* @param onError (optional) A callback function to use if any error occurs.
* @param encoding (optional) If set reads the text with the specified encoding (default UTF-8).
* Returns the text read.
*/
readText(path: string, onError?: (error: any) => any, encoding?: any): string;
/**
* Reads a text from a file with a given path.
* @param path The path to the source file.
* @param encoding (optional) If set reads the text with the specified encoding (default UTF-8).
* Returns Promise of the text read.
*/
readTextAsync(path: string, encoding?: any): Promise<string>;
/**
* Reads a text from a file with a given path.
* @param path The path to the source file.
* @param onError (optional) A callback function to use if any error occurs.
* @param encoding (optional) If set reads the text with the specified encoding (default UTF-8).
* Returns the text read.
*/
readTextSync(path: string, onError?: (error: any) => any, encoding?: any): string;
/**
* Reads a binary content from a file with a given path.
* @param path The path to the source file.
* @param onError (optional) A callback function to use if any error occurs.
* Returns the binary content read.
*/
read(path: string, onError?: (error: any) => any): any;
/**
* Reads a binary content from a file with a given path.
* @param path The path to the source file.
* Returns a Promise with the binary content read.
*/
readAsync(path: string): Promise<any>;
/**
* Reads a binary content from a file with a given path.
* @param path The path to the source file.
* @param onError (optional) A callback function to use if any error occurs.
* Returns the binary content read.
*/
readSync(path: string, onError?: (error: any) => any): any;
/**
* Writes a text to a file with a given path.
* @param path The path to the source file.
* @param content The content which will be written to the file.
* @param onError (optional) A callback function to use if any error occurs.
* @param encoding (optional) If set writes the text with the specified encoding (default UTF-8).
*/
writeText(path: string, content: string, onError?: (error: any) => any, encoding?: any);
/**
* Writes a text to a file with a given path.
* @param path The path to the source file.
* @param content The content which will be written to the file.
* @param encoding (optional) If set writes the text with the specified encoding (default UTF-8).
*/
writeTextAsync(path: string, content: string, encoding?: any): Promise<void>;
/**
* Writes a text to a file with a given path.
* @param path The path to the source file.
* @param content The content which will be written to the file.
* @param onError (optional) A callback function to use if any error occurs.
* @param encoding (optional) If set writes the text with the specified encoding (default UTF-8).
*/
writeTextSync(path: string, content: string, onError?: (error: any) => any, encoding?: any);
/**
* Writes a binary to a file with a given path.
* @param path The path to the source file.
* @param content The content which will be written to the file.
* @param onError (optional) A callback function to use if any error occurs.
*/
write(path: string, content: any, onError?: (error: any) => any);
/**
* Writes a binary to a file with a given path.
* @param path The path to the source file.
* @param content The content which will be written to the file.
*/
writeAsync(path: string, content: any): Promise<void>;
/**
* Writes a binary to a file with a given path.
* @param path The path to the source file.
* @param content The content which will be written to the file.
* @param onError (optional) A callback function to use if any error occurs.
*/
writeSync(path: string, content: any, onError?: (error: any) => any);
/**
* Gets extension of the file with a given path.
* @param path A path to the file.
*/
getFileExtension(path: string): string;
/**
* Gets the path separator (for the current platform).
*/
getPathSeparator(): string;
/**
* Normalizes a path.
* @param path A path which should be normalized.
* Returns a normalized path as string.
*/
normalizePath(path: string): string;
/**
* Joins two paths (without normalize). Only removes some trailing and duplicate path separators.
* @param left First path to join.
* @param right Second path to join.
* Returns the joined path.
*/
joinPath(left: string, right: string): string;
/**
* Joins an array of file paths.
* @param paths An array of paths.
* Returns the joined path.
*/
joinPaths(paths: string[]): string;
}