1/47
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is a filesystem
major component of any operating system
What is a filesystem responsible for?
Persistently storing, managing, and updating data on a storage device
File systems 2 abstractions
Files and directories
Files
The smallest unit of persistent data storage
File
linear array of bytes, each of which can be read or written
How are files identified?
A textual name with 2 parts separated by a dot: unique file name and file type extension
File properties
File size (bytes), file creation date, file access date, default application for file, and access permissions stating who can read, write, and execute file
What is a Directory?
a container for files
How are directories organized?
Hierarchal structure such as a tree
How are directories identified?
textual name and low-level name
What is a path?
The sequence of directory names that starts from the root directory and specifies subsequent directories until the desired file is reached
How does a path separate directory names?
special characters
What does ./ refer to?
The current directory
What does ../ refer to?
The parent directory
cat
print file content
cp
copy file
mkdir
make directory
ls
list files and directories
rm
remove file
rmdir
remove directory
pwd
print working directory
mv
move file
touch
create, change, and modify timestamps of a file
Node Buffer
special objects that handle binary data and are used to represent a fixed-length of bytes
What scope is buffer class available within?
global scope
Functions that work on buffers
alloc()
toString()
write()
length
alloc()
Creates a buffer object of a specified length
toString()
Returns the string version of a buffer object
write()
Writes a specified string to a buffer object
length
Returns the length of a buffer object in bytes
built-in modules
path and fs
path
provides utilities for working with file and directory paths
fs
enables interacting with the fie system in a way modeled on standard POSIX functions
Environment variables
_filename, _dirname
_filename
holds the absolute file name of the current module
_dirname
holds the directory name of the current module
What 3 categories does Nodejs fs module provide for accessing files?
Synchronous APIs, Callback APIs, and Promise APIs
Which are Asynchronous APIs?
Callback APIs and Promise APIs
All synchronous functions will have the term ____ added to their name
Sync
Creating a directory in JS
fs.mkdirSync(path[, options])
Read the contents of a directory
fs.readdirSync(path[, options])
remove a directory
fs.rmdirSync (path[, options])
File reading functions
readFileSync(path[, options])
readSync(fd, buffer, offset, length[, position])
readSync(fd, buffer[, options])
Reading the status of a file function
statsSync(path[, options])
Writing to a file functions
writeFileSync(file, data[, options])
writeSync(fd, buffer, offset[, length[, position]])
writeSync(fd, buffer[, options])
writeSync(fd, string[, position[, encoding]])
appendFileSync(path, data[, options])
You cannot remove a folder with files, only ones that are empty
True
Nodejs provides the ____ object which has information about, and control over, the current Nodejs process
process.argv
process.argv
holds the command line arguments passed to the Nodejs process when it is launched