Skip to main content

Multi-purpose virtual file system inside single file (ported to Python 3)

Project description

SVFS

(Quoting from the original project README):

SVFS allows to create virtual filesystem inside file on real filesystem. It can be used to store multiple files inside single file (with directory structure). Unlike archives, SVFS allows to modify files in-place. SVFS files use file-like interface, so they can be used (pretty much) like regular Python file objects. Finally, it’s implemented in pure python and doesn’t use any 3rd party modules, so it should be very portable. Tests show write speed to be around 10-12 MB/s and read speed to be around 26-28 MB/s.

Example

Following code creates SVFS, opens file in it, writes string and reads it back:

from svfs3 import SVFS #Import SVFS class

s = SVFS() # Create instance of SVFS class s.CreateSVFS('test.svfs','testvolume',100,100,100) # Create SVFS with 100 inodes and 100 blocks of 100 bytes. s.OpenSVFS('test.svfs') # Open created SVFS with s.open('testfile','w') as file: # Create and open new file for writing in SVFS. file.write('write test') # Write string into file t = s.open('testfile','r') # Open same file for reading print(t.read()) # Read entire file and print data t.close() # Close file s.CloseSVFS() # Close SVFS

That code outputs:

write test

Which means it works correctly.

Updates to v3:

SVFS now distinguishes between strings/bytes and will transparently encode/decode:

# Open up a file in text mode. 
with s.open('text_file','w', encoding='utf8') as text_file: 
    # If no encoding is given, defaults to 'utf-8'
    text_file.write("""This is a\nmultiline\ntext file""") # Write string into file, encoded as utf-8

t_file = s.open('text_file','r') # Open same file for reading
t_file.readlines()

This code outputs:

['This is a\n', 'multiline\n', 'text file']

Binary files work similarly:

# Open up a file in binary mode. 
with s.open('binary_file','wb') as binary_file: 
    # Passing 'b' as part of the mode parameter sets binary mode
    binary_file.write(b'Some bytes')

b_file = s.open('binary_file', 'rb')
b_file.read()

Outputs:

b'Some bytes'

Encrypted Files

Another update is the availability of encrypted files. Example:

s = EncryptedSVFS('keytext-must-be-at-least-32-bytes-long') 
# Create instance of EncryptedSVFS class, pass in encryption key, must be at least 32 bytes long
s.CreateSVFS('encrypted.svfs','testvolume',100,100,100) 
# Create SVFS with 100 inodes and 100 blocks of 100 bytes.
s.OpenSVFS('encrypted.svfs') # Open created SVFS
with s.open('testfile','w') as file: # Create and open new file for writing in SVFS. Contents of this file will be encrypted
    file.write('write test') # Write string into file

Now the contents of "testfile" are encrypted on disk.

t = s.open('testfile','r') # Open same file for reading
print(t.read()) # Read entire file and print data, things are transparently decrypted
t.close() # Close file
s.CloseSVFS() # Close SVFSf

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

svfs3-3.0.0.tar.gz (58.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

svfs3-3.0.0-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file svfs3-3.0.0.tar.gz.

File metadata

  • Download URL: svfs3-3.0.0.tar.gz
  • Upload date:
  • Size: 58.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for svfs3-3.0.0.tar.gz
Algorithm Hash digest
SHA256 f9dcf852cbdf6a681131e7b2de4df2bf783b3da40570505d9b5f79014b682c4d
MD5 df4e4a957a7492b626f5ee0ec4c0a62c
BLAKE2b-256 a897d517178f905abbac16f2e1e1e2999de87086c31a3aeb7e7437621d4f4108

See more details on using hashes here.

File details

Details for the file svfs3-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: svfs3-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.0

File hashes

Hashes for svfs3-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cfd39e2522d07f8b965da08dab0b09bd5638110b367522bd91649ece228cdae1
MD5 17d9dbcc8248e914bb15d5b2ad04f887
BLAKE2b-256 99e38b7571666738ec898138f95230527e8f3ddf841cf538fb50755bdbd6ae27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page