Package Exports
- file-system-explorer
- file-system-explorer/release/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (file-system-explorer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
file-system-explorer
FileSystemExplorer is an utility class with which you can:
Create
JSON objectfrom the file systemGet all
files/directories detailsfrom the file systemGet
list of files/directoriesCreate directory
Delete file/directory
Rename file/directory
Check
free mount space
from the given path and many more(s).
Installation
npm install file-system-explorerUsage
How to import file-system-explorer?
const fileSystemExplorer = require('file-system-explorer');or
import { FileSystemExplorer } from 'file-system-explorer';After import, create an object of FileSystemExplorer class.
// For JS
const fsExplorer = new fileSystemExplorer.FileSystemExplorer();or
// For TypeScript
const fsExplorer: FileSystemExplorer = new FileSystemExplorer();Create JSON object from a given path (tree like structure)
// return JSON object for directory tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');Get All Directories path from a prepared Directory Tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
// returns string[]
const myPathDirectories = fsExplorer.getAllDirectoryPathFromPreparedFSInfo(myPathTree);Get All Directories path from a given path (includes directories from the sub-directories)
// returns string[]
const myPathDirectories = fsExplorer.getAllDirectoryPathFromFileSystem('/path/to/dir/or/file'); Get All Files path from a prepared Directory Tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
const myPathFiles = fsExplorer.getAllFilePathFromPreparedFSInfo(myPathTree); // returns string[]Get All Files path from a given path (includes files from the sub-directories)
const myPathFiles = fsExplorer.getAllFilePathFromFileSystem('/path/to/dir/or/file'); // returns string[]Get All Files and Directories details from a given path (include all files/directories from sub directories)
// returns array of File/Directory details IFSInfo[]
// Details include size, file name, type, last modified time, extension, complete path
const myPathAllFSDetails = fsExplorer.getAllFSElementsDetailsFromFileSystem('/path/to/dir/or/file');Get All Files and Directories details from a prepared Directory Tree
const myPathTree = fsExplorer.createFileSystemTree('/path/to/dir/or/file');
// returns array of File/Directory details IFSInfo[]
const myPathAllFSDetails = fsExplorer.getAllFSElementsDetailsFromPreparedFSInfo(myPathTree);Get All Files and Directories details from the given path
// returns array of File/Directory details IFSInfo[]
const myPathContents = fsExplorer.getDirectoryContentList('/path/to/dir');Create Directory in a Given path
// creates 'New Folder' directory inside '/path/to/dir'
const mkdirResponse = createDirectory('/path/to/dir/New Folder', true);
// creates 'New Folder' directory inside '/path/to/dir', if already exists, then will create 'New Folder (1)'
const mkdirResponse = createDirectory('/path/to/dir');
// Return mkdirResponse.errno 0 on successDelete Directory/Files
// To delete directory, pass second paramater as true
const deleteDirResponse = deleteDirectory('/path/to/dir', true);
const deleteDirResponse = deleteDirectory('/path/to/file');
// Returns errno 0, on successRename Directory/Files
// pass rename File/Directory details IRenameFileDetails in function parameter
// IRenameFileDetails include old_path_length, old_path_, new_path_length, new_path
const renameFSResponse = renameFile('/path/to/old/dir/or/file', '/path/to/new/dir/or/file');
// Returns errno 0, on successCheck Directory Read/Write Persmission
const directoryRWPermRes = checkDirectoryReadWritePersmission('/path/to/dir');
// Returns errno 0, on successCheck FS Element Exists
// check if file exists or not
const fsElementExistsResponse = checkFSElementExists('/path/to/dir/or/file');
// Returns true, on FS Element existGet FS Element Details
// Returns FS Element IFSInfo
// Details include size, file name, type, last modified time, extension, complete path
const fsElementDetails = getFSElementDetails('/path/to/dir/or/file');Check Mount Free Space
// Check if free space available for the mount in which this file is present
const freeSpaceInBytes = checkMountFreeSpace('/path/to/dir/or/file');
// Return free space available in bytes for mount which contain the file. If command fails, return 0