TempFiles
A utility service to read, write and delete temporary files.
Constructor Summary
Public Constructor | ||
public |
constructor(info: Object, pathUtils: PathUtils, directory: string, locationName: string) Class constructor. |
Member Summary
Public Members | ||
public |
The location name for the temp directory path on the |
|
public |
A local reference for the |
Method Summary
Public Methods | ||
public |
Delete a file from the temp directory. |
|
public |
deleteSync(filepath: string): string Delete a file from the temp directory, sync version. |
|
public |
Ensure that the temp directory exists |
|
public |
ensureDirectorySync(): * Ensure that the temp directory exists, sync version. |
|
public |
Generate a path for the temp directory. |
|
public |
Read a file from the temp directory. |
|
public |
Read a file from the temp directory, sync version. |
|
public |
Write a file on the temp directory. |
|
public |
Write a file on the temp directory, sync version. |
Public Constructors
public constructor(info: Object, pathUtils: PathUtils, directory: string, locationName: string) source
Class constructor.
Params:
Name | Type | Attribute | Description |
info | Object | The application |
|
pathUtils | PathUtils | To Register the temp directory location and build the paths to the files. |
|
directory | string |
|
The name of the temp directory. |
locationName | string |
|
The name that will be used to register the temp
directory path as a location on the |
Public Members
Public Methods
public delete(filepath: string): Promise<string, Error> source
Delete a file from the temp directory.
Params:
Name | Type | Attribute | Description |
filepath | string | The path to the file. |
public deleteSync(filepath: string): string source
Delete a file from the temp directory, sync version.
Params:
Name | Type | Attribute | Description |
filepath | string | The path to the file. |
Throw:
If the method couldn't delete the file. |
public ensureDirectorySync(): * source
Ensure that the temp directory exists, sync version.
Return:
* |
Throw:
If the directory can't be created. |
public path(rest: Array): string source
Generate a path for the temp directory.
Params:
Name | Type | Attribute | Description |
rest | Array | The rest of the components that will be added to the path after the one for the temp directory. |
public read(filepath: string, encoding: string): Promise<string, Error> source
Read a file from the temp directory.
public readSync(filepath: string, encoding: string): string source
Read a file from the temp directory, sync version.
Throw:
If the file can't be read. |
public write(filepath: string, data: string): Promise<string, Error> source
Write a file on the temp directory.