Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Oblig3-myFS
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael.Olande
Oblig3-myFS
Commits
eeff4e1e
Commit
eeff4e1e
authored
4 months ago
by
David Grellscheid
Browse files
Options
Downloads
Patches
Plain Diff
Split library from main
parent
ce8f6d43
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
main.py
+46
-0
46 additions, 0 deletions
main.py
myfs.py
+0
-45
0 additions, 45 deletions
myfs.py
with
47 additions
and
45 deletions
.gitignore
+
1
−
0
View file @
eeff4e1e
myfilesystem.fs
__pycache__
This diff is collapsed.
Click to expand it.
main.py
0 → 100644
+
46
−
0
View file @
eeff4e1e
from
myfs
import
format
,
save
,
load
,
copy
,
remove
import
sys
if
len
(
sys
.
argv
)
<
2
:
# Missing filesystem name. Assuming default myfilesystem.fs
backingfile
=
'
myfilesystem.fs
'
else
:
backingfile
=
sys
.
argv
[
1
]
# one could actually use a usb stick raw at "/dev/something"
# Data loss, and it'll need reformatting afterwards!
# create backingfile if needed
try
:
with
open
(
backingfile
,
'
x
'
):
pass
except
FileExistsError
:
pass
##########################################
##########################################
alice_sample
=
"""
Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it,
'
and what is the use of a book,
'
thought Alice
'
without pictures or
conversations?
'
"""
print
()
print
(
"
*
"
*
60
)
print
(
f
"
* Use xxd
{
backingfile
}
to inspect contents
"
)
print
(
"
*
"
*
60
)
print
()
with
open
(
backingfile
,
'
r+b
'
)
as
f
:
format
(
f
)
save
(
f
,
"
hello.txt
"
,
"
Hello
"
)
save
(
f
,
"
alice.txt
"
,
alice_sample
)
alice_back
=
load
(
f
,
"
alice.txt
"
)
print
(
alice_back
)
copy
(
f
,
"
hello.txt
"
,
"
clone.txt
"
)
save
(
f
,
"
bye.txt
"
,
"
Bye Bye
"
)
copy
(
f
,
"
hello.txt
"
,
"
clone2.txt
"
)
remove
(
f
,
"
bye.txt
"
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
myfs.py
+
0
−
45
View file @
eeff4e1e
import
sys
if
len
(
sys
.
argv
)
<
2
:
# Missing filesystem name. Assuming default myfilesystem.fs
backingfile
=
'
myfilesystem.fs
'
else
:
backingfile
=
sys
.
argv
[
1
]
# one could actually use a usb stick raw at "/dev/something"
# Data loss, and it'll need reformatting afterwards!
# create backingfile if needed
try
:
with
open
(
backingfile
,
'
x
'
):
pass
except
FileExistsError
:
pass
##########################################
##########################################
# file system parameters
TOTAL_SIZE
=
0x800
# 2kB
...
...
@@ -115,34 +98,6 @@ def remove(f, filename):
##########################
##########################
alice_sample
=
"""
Alice was beginning to get very tired of sitting by her sister on the
bank, and of having nothing to do: once or twice she had peeped into the
book her sister was reading, but it had no pictures or conversations in
it,
'
and what is the use of a book,
'
thought Alice
'
without pictures or
conversations?
'
"""
if
__name__
==
"
__main__
"
:
print
()
print
(
"
*
"
*
60
)
print
(
f
"
* Use xxd
{
backingfile
}
to inspect contents
"
)
print
(
"
*
"
*
60
)
print
()
with
open
(
backingfile
,
'
r+b
'
)
as
f
:
format
(
f
)
save
(
f
,
"
hello.txt
"
,
"
Hello
"
)
save
(
f
,
"
alice.txt
"
,
alice_sample
)
alice_back
=
load
(
f
,
"
alice.txt
"
)
print
(
alice_back
)
copy
(
f
,
"
hello.txt
"
,
"
clone.txt
"
)
save
(
f
,
"
bye.txt
"
,
"
Bye Bye
"
)
copy
(
f
,
"
hello.txt
"
,
"
clone2.txt
"
)
remove
(
f
,
"
bye.txt
"
)
# ls(f)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment