1.1.11 • Published 2 years ago

file-system-explorer v1.1.11

Weekly downloads
14
License
UNLICENSED
Repository
-
Last release
2 years ago

file-system-explorer

FileSystemExplorer is an utility class with which you can:

  • Create JSON object from the file system

  • Get all files/directories details from the file system

  • Get list of files/directories

  • Create directory

  • Delete file/directory

  • Rename file/directory

  • Check free mount space

from the given path and many more(s).

Installation

npm install file-system-explorer

Usage

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 success
Delete 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 success
Rename 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 success
Check Directory Read/Write Persmission
const directoryRWPermRes = checkDirectoryReadWritePersmission('/path/to/dir');
// Returns errno 0, on success
Check FS Element Exists
// check if file exists or not
const fsElementExistsResponse = checkFSElementExists('/path/to/dir/or/file');
// Returns true, on FS Element exist
Get 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
1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.11

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago