Git Product home page Git Product logo

adf-reader-writer's Introduction

ADF reader/writer

This is an implementation of the Amiga Filesystem in plain javascript.
It can be used to read, extract and write files from/to Amiga Disk Format (*.adf) files.

Currently only standard Amiga Double Density disk are supported (the 880 kb ones)
HD floppies and HDF support is being worked on.
Both Original and Fast File System are supported.

The main module is adf.js
It uses a binary file wrapper at file.js for easy parsing binary data.

The rest of the package is a small demo, providing a simple user interface to browse the disk.
Live demo at http://www.stef.be/adfviewer/

It can disregard all block checksums and file attributes, which makes it quite useful to salvage files from corrupt disks. For further digging, you can also extract raw sectors for reconstructing deleted files etc.

I mainly wrote it to quickly inspect .adf files for Amiga music tracker files or Emerald Mine disks without the need to fire up an Amiga Emulator.
Basic writing support was added for interaction with the Scripted Amiga Emulator

Main API:

adf.loadDisk(source)

Loads a disk from an adf file. When source is a string, it's considered as a URI, otherwise you can pass an ArrayBuffer.
All future actions will be done on this disk.

adf.getInfo()

Returns some basic info on the disk.

adf.getFreeSize()

Returns the used and free space of the disk (in blocks and KB)

adf.readRootFolder()

Returns the files and directories of the root folder of the disk.
Each file and folder has a sector parameters which points to the start sector of the file or folder.

adf.readFolderAtSector(sector)

Returns the files and directories of a specific folder that starts at sector.
The starting sector is usually obtained from listing the root folder.
Each file and folder has a sector parameters which points to the start sector of the file or folder.
Each file and folder also has a parent parameter indicating the parent folder so you can traverse back up.

adf.readFileAtSector(sector,includeContent)

Returns the file info (and optional content) of the file starting at sector
The starting sector is usually obtained from listing a folder.
If includeContent is true then the content parameter contains the binary content of the file.

adf.writeFile(name,buffer,folderSector)

Creates a new file into a specific folder.
It returns the sector of the new file on succes or False on failure. (e.g. because diskspace is insufficient) Buffer is an ArrayBuffer with the binary content Sequential datablocks are used as much as possible to speed up reading on an actual (or emulated) Amiga."

adf.deleteFileAtSector(sector)

Deletes a file
Just as on the Amiga only the entry of the file in its folder is removed, all the header and datablocks are left intact, so it's possible to reconstruct the file as long as no new data is written to the disk.

adf.createFolder(name,folderSector)

Creates a folder.
it returns the sector of the new folder

adf.deleteFolderAtSector(sector)

Deletes a folder Please note that the folder must me empty so for recursive deletion you should first list the folder, then delete all files and finally delete the folder

adf.renameFileOrFolderAtSector(sector,newname)

Renames a file or a folder.
the maximum length of a name is 30 chars.
the characters / and : are not allowed

additional API

The following methods are available for low level disk reading

readSector(sector)

Returns a raw sector from the disk.
A sector of a standard Amiga is 512 bytes

getSectorType(sector)

Returns the type of the sector (headerBlock, dataBlock, extentionBlock, ...)

readHeaderBlock(sector)

Returns a parsed headerBlock

readDataBlock(sector)

Returns a parsed dataBlock

readExtentionBlock(sector)

Returns a parsed extentionBlock

getDisk()

Returns the currect disk structure. the "buffer" property contains the binary data of the disk

Notes

Writing support is still a bit experimental.
Don't use it for important stuff, it certainly is not production ready.
When writing, all dates are ignore for the time being, so "last changed" and "last accessed" dates will not be updated.

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.