Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
55dd394e
Commit
55dd394e
authored
Jun 17, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some fixes to improve fuse support
parent
043da7d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
8 deletions
+28
-8
fs/memoryfs.py
+28
-8
No files found.
fs/memoryfs.py
View file @
55dd394e
...
@@ -3,9 +3,10 @@
...
@@ -3,9 +3,10 @@
fs.memoryfs
fs.memoryfs
===========
===========
A Filesystem that exists in memory only.
A Filesystem that exists in memory only. Which makes them extremely fast, but non-permanent.
If you open a file from a `memoryfs` you will get back a StringIO object from the standard library.
File objects returned by MemoryFS.objects use StringIO objects for storage.
"""
"""
...
@@ -37,7 +38,12 @@ class MemoryFile(object):
...
@@ -37,7 +38,12 @@ class MemoryFile(object):
self
.
mem_file
=
None
self
.
mem_file
=
None
if
_check_mode
(
mode
,
'wa'
):
if
'+'
in
mode
:
self
.
mem_file
=
StringIO
()
self
.
mem_file
.
write
(
value
)
self
.
mem_file
.
seek
(
0
)
elif
_check_mode
(
mode
,
'wa'
):
self
.
mem_file
=
StringIO
()
self
.
mem_file
=
StringIO
()
self
.
mem_file
.
write
(
value
)
self
.
mem_file
.
write
(
value
)
...
@@ -50,6 +56,7 @@ class MemoryFile(object):
...
@@ -50,6 +56,7 @@ class MemoryFile(object):
elif
_check_mode
(
mode
,
'r'
):
elif
_check_mode
(
mode
,
'r'
):
self
.
mem_file
=
StringIO
(
value
)
self
.
mem_file
=
StringIO
(
value
)
self
.
mem_file
.
seek
(
0
)
elif
_check_mode
(
mode
,
"a"
):
elif
_check_mode
(
mode
,
"a"
):
self
.
mem_file
=
StringIO
()
self
.
mem_file
=
StringIO
()
...
@@ -153,9 +160,9 @@ class DirEntry(object):
...
@@ -153,9 +160,9 @@ class DirEntry(object):
def
desc_contents
(
self
):
def
desc_contents
(
self
):
if
self
.
isfile
():
if
self
.
isfile
():
return
"<file
%
s>"
%
self
.
name
return
"<file
%
s>"
%
self
.
name
elif
self
.
isdir
():
elif
self
.
isdir
():
return
"<dir
%
s>"
%
""
.
join
(
"
%
s:
%
s"
%
(
k
,
v
.
desc_contents
())
for
k
,
v
in
self
.
contents
.
iteritems
())
return
"<dir
%
s>"
%
""
.
join
(
"
%
s:
%
s"
%
(
k
,
v
.
desc_contents
())
for
k
,
v
in
self
.
contents
.
iteritems
())
def
isdir
(
self
):
def
isdir
(
self
):
return
self
.
type
==
"dir"
return
self
.
type
==
"dir"
...
@@ -172,9 +179,7 @@ class DirEntry(object):
...
@@ -172,9 +179,7 @@ class DirEntry(object):
class
MemoryFS
(
FS
):
class
MemoryFS
(
FS
):
""" An in-memory filesystem.
"""An in-memory filesystem.
MemoryFS objects are very fast, but non-permantent. They are useful for creating a directory structure prior to writing it somewhere permanent.
"""
"""
...
@@ -428,6 +433,21 @@ class MemoryFS(FS):
...
@@ -428,6 +433,21 @@ class MemoryFS(FS):
del
src_dir_entry
.
contents
[
src_name
]
del
src_dir_entry
.
contents
[
src_name
]
def
settimes
(
self
,
path
,
accessed_time
=
None
,
modified_time
=
None
):
now
=
datetime
.
datetime
.
now
()
if
accessed_time
is
None
:
accessed_time
=
now
if
modified_time
is
None
:
modified_time
=
now
dir_entry
=
self
.
_get_dir_entry
(
path
)
if
dir_entry
is
not
None
:
dir_entry
.
accessed_time
=
accessed_time
dir_entry
.
modified_time
=
modified_time
return
True
return
False
@synchronize
@synchronize
def
_on_close_memory_file
(
self
,
open_file
,
path
,
value
):
def
_on_close_memory_file
(
self
,
open_file
,
path
,
value
):
filepath
,
filename
=
pathsplit
(
path
)
filepath
,
filename
=
pathsplit
(
path
)
...
...
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