Skip to main content

FAT12/FAT16/FAT32 implementation with VFAT support

Project description

CI build status Read the Docs Test coverage overview Codacy Code Quality PyPI - Python Version PyPI MIT License

pyfatfs

pyfatfs is a filesystem module for use with PyFilesystem2 for anyone who needs to access or modify files on a FAT filesystem. It also provides a low-level API that allows direct interaction with a FAT filesystem without PyFilesystem2 abstraction.

pyfatfs supports FAT12/FAT16/FAT32 as well as the VFAT extension (long file names).

Installation

pyfatfs is available via PyPI as pyfatfs, so just execute the following command to install the package for your project:

$ pip install pyfatfs

Usage

The easiest way to get started with pyfatfs is to use it in conjunction with PyFilesystem2:

PyFilesystem2

Use fs.open_fs to open a filesystem with a FAT FS URL:

import fs
my_fs = fs.open_fs("fat:///dev/sda1")

Parameters

It is possible to supply query parameters to the URI of the PyFilesystem2 opener to influence certain behavior; it can be compared to mount options. Multiple parameters can be supplied by separating them via ampersand (&).

encoding

pyfatfs offers an encoding parameter to allow overriding the default encoding of ibm437 for file names, which was mainly used by DOS and still is the default on Linux.

Any encoding known by Python can be used as value for this parameter, but keep in mind that this might affect interoperability with other systems, especially when the selected encoding/codepage is not native or supported.

Please note that this only affects encoding of the 8DOT3 short file names, not long file names of the VFAT extension, as LFN are always stored as UTF-16-LE.

import fs
my_fs = fs.open_fs("fat:///dev/sda1?encoding=cp1252")
offset

Specify an offset in bytes to skip when accessing the file. That way even complete disk images can be read if the location of the partition is known:

import fs
my_fs = fs.open_fs("fat:///dev/sda?offset=32256")
preserve_case

Preserve case when creating files. This will force LFN entries for all created files that do not match the 8DOT3 rules. This defaults to true but can be disabled by setting preserve_case to false:

import fs
my_fs = fs.open_fs("fat:///dev/sda1?preserve_case=false")
read_only

Open filesystem in read-only mode and thus don’t allow writes/modifications. This defaults to false but can be enabled by setting read_only to true:

import fs
my_fs = fs.open_fs("fat:///dev/sda1?read_only=true")
utc

Create all timestamps on the filesystem in UTC time rather than local time. Affects all directory entries’ creation, modification and access times.

import fs
my_fs = fs.open_fs("fat:///dev/sda1?utc=true")
lazy_load

If set to true (default), the directory entries are loaded only when accessed to increase performance with larger filesystems and resilience against recursion / directory loops.

import fs
my_fs = fs.open_fs("fat:///dev/sda1?lazy_load=false")

Testing

Tests are located at the tests directory. In order to test your new contribution to pyfatfs just run

$ python setup.py test

from your shell.

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

pyfatfs-1.1.0.tar.gz (55.5 kB view details)

Uploaded Source

Built Distribution

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

pyfatfs-1.1.0-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

Details for the file pyfatfs-1.1.0.tar.gz.

File metadata

  • Download URL: pyfatfs-1.1.0.tar.gz
  • Upload date:
  • Size: 55.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pyfatfs-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9725ccd0a4da1c09c27358abbf10f08c043ac84210af576803e087f51a2b30e0
MD5 df7f61cdec5567ec16956cbae14514e0
BLAKE2b-256 443fd08f1dbc44a7eef9c7fb355b83423fbd15bb3e487c250479a2c179cb39bf

See more details on using hashes here.

File details

Details for the file pyfatfs-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyfatfs-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pyfatfs-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7401fd39d9e92f531b2abea5b5d1d2c19d5461f4ba9ce8819b1ba35aea73c65d
MD5 403c665c96b4b5ab7ea1f97f4c8850d2
BLAKE2b-256 cbdefeb531b25eb2315aa73a7dba335c253ee0075ff7f55b6fe742fb6d492ade

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