Skip to content

mku11/SimpleFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleFS

A simple and performant filesystem API. The syntax is easy and consistent across all language/platform implementations. Available for the following: Java, Android, C#, .NET Android, Python, TypeScript/JavaScript.
Published under MIT License

License: MIT Version GitHub Releases

Features

  • Abstract file system API with common file operations: create, delete, read, write, list, copy, move, etc
  • Abstract Virtual drive with support for parallel batch import/export/delete/search file operations.

Implementations

  • Java (Local Read/Write)
  • C# (Local Read/Write .NET 8+, no support for UWP Windows Storage, no support for IsolatedStorage)
  • Android: (Supports internal and external SD cards with Android Storage Framework)
  • .NET Android: (Supports internal and external SD cards with Android Storage Framework)
  • Python (Local files Read/Write)
  • TypeScript/JavaScript (supports node.js, browser FileSystemHandle API, and limited virtual localStorage)
  • Http (Read-Only, supports Basic Auth)
  • WebService (Read/Write, compatible with WebFS, supports Basic Auth)

API Docs

Java
C#
Python
TypeScript

Example

The API is consistent across all platforms/languages, this example is for Java.

  1. Get a directory:
// For local directory (read/write):
File dir = new File("C:\my_local_directory");

// For remote HTTP directory (read-only):  
HttpFile dir = new HttpFile("https://localhost/my_remote_directory");

// HTTP remote directory with Basic Auth (read-only):  
HttpFile dir = new HttpFile("https://localhost/my_remote_directory/",  new Credentials("user", "password"));

// Web Service remote directory, compatible with WebFS (read/write):
WSFile dir = new WSFile("/my_remote_directory", "https://localhost:8443",  new Credentials("user", "password"));
  1. List files:
File[] files = dir.listFiles();
  1. Read a file:
RandomAccessStream stream = file.getInputStream();
stream.seek();
stream.read();
stream.close();
  1. Write a file:
RandomAccessStream stream = file.getOutputStream();
stream.seek();
stream.write();
stream.close();
  1. Other operations:
file.getName();
file.getPath();
file.getParent();
file.exists();
file.delete();
file.isFile();
file.isDirectory();
file.copy();
file.move();
...
  1. To import/copy a file in a directory using multiple threads you can use FileImporter:
FileImporter importer = new FileImporter();
importer.initialize(bufferSize, threads);
FileImportOptions options = new FileImportOptions();
options.onProgressChanged = (pos, len) -> {
	System.out.println("bytes copied: " + position);
};
IVirtualFile importFile(fileToImport, dir, options);
importer.close();
  1. To import files in batches use FileCommander:
FileCommander commander = new FileCommander(new FileImporter(), new FileExporter(), new FileSearcher());
File[] importedFiles = commander.importFiles(files, dir);
commander.close();
  1. To search for a file by filename:
SearchOptions options = new SearchOptions();
options.onResultFound = (file) -> {
	System.out.println("File found: " + file.getPath());
}
File[] files = searcher.search(dir, "filename.txt", options);

About

Library filesystem API for C#, Java, TS/JS, and Python

Resources

License

Stars

Watchers

Forks

Packages

No packages published