In this section we will dive into the basics of Unix based file systems. Particularly, you will discover notions of file descriptors, users / groups access permissions, special files etc.
- Read about typical file system structure in Unix Systems
- Discover unix file permissions and access modes
- 🚦Node.js🚦 Node.js File System
- 🚦Golang🚦 Working with Files in Go
- 🚦Python🚦 Working With Files in Python
- Create folder called
file_system
folder in yourkottans-backend
repo - In
file_system
folder:- create file called
secret.txt
- grant read-write-execute permissions to owned user, read-only permission to owned group and no permissions to other users for file
secret.txt
. Permission indicator for this file should be:-rwxr-----
- commit and push your changes to remote
- create file called
- 🚦Node.js🚦 In your
file_system
folder create filefile_system_task.js
. In this file, implement a program with the following behavior:- Upon run (with
node file_system_task.js
), program checks whether or not filecounter.txt
exists. - If its not. Program creates new file
counter.txt
with write/read/execute access to all users. Then it writes single digit1
into the file, closes it and exits with status code 0 (normal exit). - If it does exist. Program opens the file
counter.txt
, reads its content and checks whether or not all the content of the file is valid integer. If it's valid integer, program increments counter by one, writes new digit into the file (replaces previous one), closes the file and exits with status code 0 (normal exit). If its not valid immediately exists with status code 1 (abnormal exit).
- Upon run (with
- 🚦Golang🚦 In your
file_system
folder create filefile_system_task.go
. Within this file, implement program with the following behavior:- Upon run (with
go run file_system_task.go
, consider that yourfile_system_task.go
should havemain
function to be executable), program checks whether or not filecounter.txt
exists. - If its not. Program creates new file
counter.txt
with write/read/execute access to all users. Writes single digit1
into the file, closes it and exits with status code 0 (normal exit). - If it does exist. Program opens the file
counter.txt
, reads its content and checks whether or not all the content of the file is valid integer. If it's valid integer, program increments counter by one, writes new digit into the file (replaces previous one), closes the file and exits with status code 0 (normal exit). If its not valid immediately exists with status code 1 (abnormal exit).
- Upon run (with
- 🚦Python🚦 In your
file_system
folder create filefile_system_task.py
. Within this file, implement program with the following behavior:- Upon run (with
python3 file_system_task.py
), program checks whether or not filecounter.txt
exists. - If its not. Program creates new file
counter.txt
with write/read/execute access to all users. Writes single digit1
into the file, closes it and exits with status code 0 (normal exit). - If it does exist. Program opens the file
counter.txt
, reads its content and checks whether or not all the content of the file is valid integer. If it's valid integer, program increments counter by one, writes new digit into the file (replaces previous one), closes the file and exits with status code 0 (normal exit). If its not valid immediately exists with status code 1 (abnormal exit).
- Upon run (with
- In your
kottans-backend
repoREADME.md
:- add header
## File System
- embed the links to your
secret.txt
file andfile_system_task
source code file.
- add header
- You did lot already! If you honestly finished all the previous steps then go ahead
and share it with others –
post a message in course channel:
File System — #done
and add the link to your repo. This step is important, as it helps mentors to track your progress!
- 🚦Node.js🚦 Node.js docs on
fs
module - 🚦Golang🚦 Reading files in various use cases. Golang tutorial series. No. 35.
- 🚦Node.js🚦 Руководство по Node.js, часть 9: работа с файловой системой
- 🚦Python🚦 Awesome
pathlib
package
➡️ Go forward to Runtime, Ecosystem and I/O