Memfs¶
Description:
- Work with data in memory. In-Memory Object Storage FileSystem based on Trie data-structure.
Resources:
Example 1¶
Create text files in memory and find them
In [ ]:
Copied!
from pathlib import Path
from morefs.memory import MemFS
fs = MemFS()
# Create a dir and define files to be created
fp = "/tmp/ganymede_demo"
path = Path(fp).mkdir(exist_ok=True)
test_fp1 = f"{fp}/test1.txt"
test_fp2 = f"{fp}/test2.txt"
# Create the files in memory
fs.touch(test_fp1)
fs.touch(test_fp2)
files = fs.find("")
print(files)
from pathlib import Path
from morefs.memory import MemFS
fs = MemFS()
# Create a dir and define files to be created
fp = "/tmp/ganymede_demo"
path = Path(fp).mkdir(exist_ok=True)
test_fp1 = f"{fp}/test1.txt"
test_fp2 = f"{fp}/test2.txt"
# Create the files in memory
fs.touch(test_fp1)
fs.touch(test_fp2)
files = fs.find("")
print(files)