Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
scan-filesystem
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
scan-filesystem
Commits
f167804a
Commit
f167804a
authored
Oct 13, 2022
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to json
parent
f9c8da8c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
29 deletions
+44
-29
scan.pyx
scan.pyx
+44
-29
No files found.
scan.pyx
View file @
f167804a
...
...
@@ -20,38 +20,45 @@ cdef Str sep = Str("/")
cdef
char
*
file_fmt
=
"""
\
[{}]
type = file
sha256 = {}
sha512 = {}
{}
"{}": {{
"type": "file",
"sha256": "{}",
"sha512": "{}",
"stat":
{}
}},
"""
cdef
char
*
dir_fmt
=
"""
\
[{}]
type = dir
{}
"{}": {{
"type": "dir",
"entries": ["{}"],
"stat": {}
}},
"""
cdef
char
*
symlink_fmt
=
"""
\
[{}]
type = symlink
target = {}
{}
"{}": {{
"type": "symlink",
"target": "{}",
"stat":
{}
}},
"""
cdef
char
*
stat_fmt
=
"""
\
dev = {}
ino = {}
mode = {}
nlink = {}
owner = {{ uid = {}, gid = {} }}
rdev = {}
sizes = {{ size = {}, blksize = {}, blocks = {} }}
times = {{ atim = [{}, {}], mtim = [{}, {}], ctim = [{}, {}] }}"""
cdef
char
*
stat_fmt
=
"""{{
"dev": {},
"ino": {},
"mode": {},
"nlink": {},
"uid": {},
"gid": {},
"rdev": {},
"size": {},
"blksize": {},
"blocks": {},
"atim": [{}, {}],
"mtim": [{}, {}],
"ctim": [{}, {}]
}}"""
cdef
lock
Scheduler
scheduler
=
Scheduler
()
...
...
@@ -71,7 +78,7 @@ cdef cypclass Node activable:
void
write_node
(
self
,
FILE
*
stream
):
pass
Str
to_
toml
(
self
):
Str
to_
json
(
self
):
return
format
(
stat_fmt
,
self
.
stat
.
st_dev
,
self
.
stat
.
st_ino
,
...
...
@@ -134,12 +141,12 @@ cdef cypclass DirNode(Node):
self
.
text
=
format
(
dir_fmt
,
self
.
path
,
self
.
to_toml
(),
Str
(
'", "'
).
join
(
entries
)
if
entries
is
not
NULL
else
Str
(
""
),
self
.
to_json
(),
)
for
active_child
in
self
.
children
:
active_child
.
build_node
(
NULL
)
pass
void
write_node
(
self
,
FILE
*
stream
):
os
.
write
(
self
.
text
,
stream
)
...
...
@@ -194,9 +201,12 @@ cdef cypclass FileNode(Node):
self
.
path
,
self
.
sha256
if
self
.
sha256
else
Str
(
"<error>"
),
self
.
sha512
if
self
.
sha512
else
Str
(
"<error>"
),
self
.
to_
toml
(),
self
.
to_
json
(),
)
void
write_node
(
self
,
FILE
*
stream
):
os
.
write
(
self
.
text
,
stream
)
cdef
cypclass
SymlinkNode
(
Node
):
Str
target
...
...
@@ -210,9 +220,12 @@ cdef cypclass SymlinkNode(Node):
self
.
text
=
format
(
symlink_fmt
,
self
.
path
,
target
,
self
.
to_
toml
(),
self
.
to_
json
(),
)
void
write_node
(
self
,
FILE
*
stream
):
os
.
write
(
self
.
text
,
stream
)
cdef
int
scan
(
iso
Str
path
)
nogil
:
root
=
Node
.
node
(
consume
path
)
...
...
@@ -223,7 +236,9 @@ cdef int scan(iso Str path) nogil:
scheduler
.
join
()
os
.
write
(
Str
(
"{"
),
os
.
stdout
)
root
.
write_node
(
os
.
stdout
)
os
.
write
(
Str
(
' "":
\
n
}'
),
os
.
stdout
)
return
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment