fs

package
v3.2.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2024 License: MIT, Apache-2.0 Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListDir

func ListDir(path string, itemType string) ([]string, error)

ListDir lists itemType values within a directory depending on the itemType provided itemType can be any one of ['file','dir',”] @example ```javascript const fs = require('nuclei/fs'); // this will only return files in /tmp directory const files = fs.ListDir('/tmp', 'file'); ``` @example ```javascript const fs = require('nuclei/fs'); // this will only return directories in /tmp directory const dirs = fs.ListDir('/tmp', 'dir'); ``` @example ```javascript const fs = require('nuclei/fs'); // when no itemType is provided, it will return both files and directories const items = fs.ListDir('/tmp'); ```

func ReadFile

func ReadFile(path string) ([]byte, error)

ReadFile reads file contents within permitted paths and returns content as byte array @example ```javascript const fs = require('nuclei/fs'); // here permitted directories are $HOME/nuclei-templates/* const content = fs.ReadFile('helpers/usernames.txt'); ```

func ReadFileAsString

func ReadFileAsString(path string) (string, error)

ReadFileAsString reads file contents within permitted paths and returns content as string @example ```javascript const fs = require('nuclei/fs'); // here permitted directories are $HOME/nuclei-templates/* const content = fs.ReadFileAsString('helpers/usernames.txt'); ```

func ReadFilesFromDir

func ReadFilesFromDir(dir string) ([]string, error)

ReadFilesFromDir reads all files from a directory and returns a string array with file contents of all files @example ```javascript const fs = require('nuclei/fs'); // here permitted directories are $HOME/nuclei-templates/* const contents = fs.ReadFilesFromDir('helpers/ssh-keys'); log(contents); ```

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL