Giter VIP home page Giter VIP logo

node-fat32's Introduction

FAT32 File System

npm npm license npm downloads build status

FAT12/16/32 file system driver

Install via npm

$ npm install --save fat32

Features

  • Reading volume boot & information sector
  • Reading of clusters and cluster chains
  • Write support
  • Node fs compatible API
  • Defragmentation
  • Transactions (if multiple FATs are present)

Usage

Related Modules

  • ExFAT - ExFAT file system driver
  • NTFS - NTFS file system driver
  • HFS+ - HFS+ file system driver
  • Ext4 - Ext4, Ext3, Ext2 file system driver
  • MBR - Master Boot Record (MBR)
  • GPT - GUID Partition Table (GPT)
  • BlockDevice - Reads from & writes to block devices, or treats files as block devices
  • Disk - Handles a formatted block device (reads the MBR and GPT, creates bounded partitions with BlockDevice APIs)

Mounting a partition from a block device

var BlockDevice = require( 'blockdevice' )
var Disk = require( 'disk' )
var FAT = require( 'fat32' )

var device = new BlockDevice({
  path: '/dev/rdisk2', // or i.e. '\\\\.\\PhysicalDrive2' on Windows
})

var disk = new Disk( device )
var volume = new FAT.Volume()

disk.open(( error ) => {

  // For purposes of demonstration, error handling will
  // not be tended to in this example, but should of course
  // be implemented in real-world use cases
  if( error ) return handleError( error )

  // Find a FAT formatted partition
  var partNo = disk.mbr.partitions.findIndex(( partition ) => {
    return partition.type === 0x0B || partition.type === 0x0C
  })

  // Mount the partition (with a BlockDevice API)
  volume.mount( disk.partitions[ partNo ], null, ( error ) => {
    console.log( util.inspect( volume ) )
    // ...
    volume.unmount(( error ) => {
      disk.close(( error ) => {
        // ...
      })
    })
  })

})
Volume {
  device: Partition {
    device: BlockDevice {
      fd: 13,
      path: '/dev/rdisk2',
      mode: 'r',
      blockSize: 512,
      size: -1,
      headsPerTrack: -1,
      sectorsPerTrack: -1
    },
    firstLBA: 8192,
    lastLBA: 137216
  },
  bits: 32,
  readOnly: true,
  vbr: VBR {
    jmp: <Buffer eb 58 90>,
    oemName: 'mkfs.fat',
    sectorSize: 512,
    sectorsPerCluster: 1,
    reservedSectors: 32,
    numberOfFATs: 2,
    rootDirEntries: 0,
    sectorCount: 129024,
    mediaType: 248,
    sectorsPerFAT: 993,
    sectorsPerTrack: 32,
    numberOfHeads: 64,
    hiddenSectors: 0,
    fsType: 'FAT32   ',
    flags: 0,
    version: '0.0',
    rootClusterSector: 2,
    fsInfoSector: 1,
    mirrorSector: 6,
    reserved: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00>,
    driveNumber: 128,
    corrupted: 0,
    extendedSignature: 41,
    id: 1892531337,
    name: 'boot       ',
    code: <Buffer 0e 1 f be 77 7 c ac 22 c0 74 0b 56 b4 0e bb 07 00 cd 10 5e eb f0 32 e4 cd 16 cd 19 eb fe 54 68 69 73 20 69 73 20 6e 6 f 74 20 61 20 62 6 f 6 f 74 61 62 6 c...>,
    signature: 43605,
    rootCluster: 2
  },
  info: FSInfo {
    reserved1: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00...>,
    freeClusters: 85480,
    lastCluster: 41530,
    reserved2: <Buffer 00 00 00 00 00 00 00 00 00 00 00 00>
  },
  tables: [{
    id: 268435448,
    eoc: 4279238655,
    buffer: <Buffer f8 ff ff 0 f ff ff ff 07 65 00 00 00 ac a0 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0 a 00 00 00 0b 00 00 00 0 c 00 00 00 0 d 00...>
  }, {
    id: 268435448,
    eoc: 4279238655,
    buffer: <Buffer f8 ff ff 0 f ff ff ff 07 65 00 00 00 ac a0 00 00 05 00 00 00 06 00 00 00 07 00 00 00 08 00 00 00 09 00 00 00 0 a 00 00 00 0b 00 00 00 0 c 00 00 00 0 d 00...>
  }]
}

References

node-fat32's People

Contributors

jhermsmeier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-fat32's Issues

Possible to use node-fat32 to see inside an .AAF file?

An AAF File (Advanced Authoring Format) is a media and data interchange file format for film and video post production (More here)

The reason it might be relevant here is that it's a file format that 'is basically a FAT32 filesystem in a file and AAF uses “directories” as classes and “files” to store property metadata.' (Source)

Not totally familiar with the technical particulars of FAT32 but I wonder the possibility of using node-fat32 to look at an .aaf file similar to how you might work with, for instance /dev/disk2?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.