• Stars
    star
    130
  • Rank 276,692 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

(Deprecated!) JavaScript FileSystemObject library for temporary and permanent client-side file storage

FSO.js

The file system API that this project is based on has been deprecated, and is no longer supported by most major browsers. This repository exists for archival purposes only.

FSO.js is a JavaScript FileSystemObject library for temporary and permanent client-side file storage.

This ReadMe serves as the official documentation for FSO.js.

For more in-depth information about the project, visit FSOjs.com.

Detailed example code is available at FSOjs - Examples.

Tweet the creator (me!) at @keithwhor

Getting Started

FSO can be included on any webpage using:

<script src="your_script_path/fso.min.js"></script>

And a typical use case might be:

var fso = new FSO(1024 * 1024 * 1024, false); // Create 1GB of temp storage

var fsq = fso.createQueue();

// Queues process commands sequentially,
// prepare your queue like so:
fsq.mkdir('hello');
fsq.write('hello/world.txt', 'Hello World');
fsq.read('hello/world.txt', function(data) { console.log(data); });

// Finally, execute asynchronously.
fsq.execute();

FSO

FSO

FSO(
	opt_int_byteSize, [ = 1024 * 1024 * 1024 (1GB) ]
	opt_bool_persisent, [ = false ]
	opt_fn_successCallback,
	opt_fn_errorCallback
)

The main FSO.js constructor

returns FSO instance

Instantiate using var fso = new FSO();


FSO.createQueue

createQueue()
[ returns new FSOQueue ]

returns new FSOQueue instance


FSO.toURL

toURL(
	str_fullPath
)
[ returns str_resourceURL ]

returns a resource URL for specified fullPath


FSOQueue

FSOQueue.write

write(
	string_fullFilePath,
	string_data OR arrayBuffer_data OR array_data,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Writes a file to an existing directory.

Creates files if they do not exist.

Truncates and overwrites existing files.


FSOQueue.append

append(
	string_fullFilePath,
	string_data OR arrayBuffer_data OR array_data,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Appends data to an existing file.

Creates files if they do not exist.


FSOQueue.insert

insert(
	string_fullFilePath,
	string_data OR arrayBuffer_data OR array_data,
	int_byteOffset,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Inserts data to existing file at byteOffset.

Overwrites file data at byteOffset to data length.

Zeroes out all data between current file length and byteOffset.

Creates files if they do not exist.


FSOQueue.put

put(
	file_File,
	string_fullPath,
	opt_string_name,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Places a File Object (i.e. result of file selection) at fullPath.

Will use given name if name not provided, or given a falsey value (i.e. empty string or null).

Overwrites existing files with the same name.


FSOQueue.mkdir

mkdir(
	string_fullPath,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Recursively creates all directories in fullPath if they do not exist


FSOQueue.rm

rm(
	string_fullPath,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Removes an existing file or empty directory at fullPath.


FSOQueue.rmdir

rmdir(
	string_fullPath,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Recursively removes a directory (including contents) at fullPath.


FSOQueue.rename

rename(
	string_fullPath,
	string_name,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Renames file or directory at fullPath to name.


FSOQueue.move

move(
	string_fullPath,
	string_toPath,
	opt_string_name,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Moves file or directory at fullPath to toPath with optional name name.

name will remain unchanged if provided with a falsey value.


FSOQueue.copy

copy(
	string_fullPath,
	string_toPath,
	opt_string_name,
	opt_fn_successCallback
)
[ returns FSOQueue ]

Copies file or directory at fullPath to toPath with optional name name.

name will remain unchanged if provided with a falsey value.


FSOQueue.read

read(
	string_fullPath,
	fn_successCallback [ arguments str_data ]
)
[ returns FSOQueue ]

Reads file at fullPath and returns data to first argument of successCallback.


FSOQueue.readBuffer

readBuffer(
	string_fullPath,
	fn_successCallback [ arguments arrayBuffer_data ]
)
[ returns FSOQueue ]

Reads file at fullPath and returns data to first argument of successCallback.


FSOQueue.info

info(
	string_fullPath,
	fn_successCallback [ arguments obj_fileData ]
)
[ returns FSOQueue ]

Reads file metadata at fullPath and returns fileData to first argument of successCallback.


FSOQueue.list

list(
	string_fullPath,
	int_depth,
	fn_successCallback [ arguments obj_nestedList ]
)
[ returns FSOQueue ]

Reads directory contents of fullPath recursively to depth directories deep, and returns nestedList to first argument of successCallback.

If depth === null, will return full listing.

Use FSOUtil.prettyDirectory for quick nestedList prettification.


FSOQueue.getBytes

getBytes(
	fn_successCallback [ arguments int_usedBytes, int_availableBytes ]
)
[ returns FSOQueue ]

Returns usedBytes, availableBytes to first two arguments of successCallback, respectively.

availableBytes represents the total available space, including usedBytes - not the remaining space.


FSOQueue.execute

execute(
	opt_fn_successCallback,
	opt_fn_errorCallback [ arguments obj_error ]
)
[ returns FSOQueue ]

Executes a queue, prevents new commands from being queued, and runs successCallback on queue completion.

errorCallback will override default error reporting and run on failure of any command in the queue.


FSOUtil

A static object containing useful utilities


FSOUtil.prettyDirectory

prettyDirectory(
	object_nestedList
)
[ returns str_prettyList ]

Returns a prettified (text) directory listing of nestedList


FSOUtil.prettySize

prettySize(
	int_bytes
)
[ returns str_prettySize ]

Returns a prettified (text) size of bytes


More Repositories

1

nodal

API Services Made Easy With Node.js
JavaScript
4,515
star
2

multithread.js

In-browser multithreading made easy
JavaScript
686
star
3

audiosynth

JS Dynamic Audio Synth
JavaScript
599
star
4

UnitGraph

Lightweight Graph Library for Node 4.x
JavaScript
261
star
5

NtSeq

JavaScript (node + browser) bioinformatics library for nucleotide sequence manipulation and analysis.
JavaScript
208
star
6

cmnd

Command Line Interface Utility for Node.js using ES6 idioms
JavaScript
165
star
7

canvasBlurRect

Real-time (30+ FPS) iOS-style box blur + saturation with HTML5 Canvas
JavaScript
87
star
8

nodal-graphql

GraphQL Example Nodal Application
JavaScript
55
star
9

NCBIConnect

JavaScript library for interfacing with National Center for Biotechnology Information's databases
JavaScript
16
star
10

inherit.js

A more elegant way to prototype
JavaScript
16
star
11

nodal-angular

Nodal Angular SPA Initializer & Helpers
JavaScript
10
star
12

instatweet-api

Nodal Example (0.7.x), Instatweet API server
JavaScript
10
star
13

halo-stat-notifier

Halo: Master Chief Collection Stat Notifier, send an SMS to tell your friends you're online
JavaScript
9
star
14

stdlib-sequence

StdLib DNA Sequence Alignment Service
JavaScript
6
star
15

APIConnect

Quick and Easy RESTful API XHR Library
JavaScript
6
star
16

api-res

Node.js HTTP(S) Request Library intended for Nodal API Services
JavaScript
4
star
17

casino

A module for simulating and playing Blackjack games
JavaScript
4
star
18

cubicBezier.js

Simple cubic bezier interpolator (find Y given X) for mimicking CSS transitions
JavaScript
2
star
19

tobi-said-autocode

Replies with a YouTube video when a Slack message starts with "Tobi said"
JavaScript
1
star