Skip to content

Commit

Permalink
Code organization
Browse files Browse the repository at this point in the history
Fixed backends being exported directly without Create patched
Removed dead code
  • Loading branch information
james-pre committed Sep 10, 2023
1 parent 0592e5b commit 51233a1
Show file tree
Hide file tree
Showing 29 changed files with 430 additions and 509 deletions.
7 changes: 0 additions & 7 deletions src/README.md

This file was deleted.

7 changes: 3 additions & 4 deletions src/backend/AsyncMirror.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type FileSystem, SynchronousFileSystem } from '../core/file_system';
import { ApiError, ErrorCode } from '../core/api_error';
import { FileFlag } from '../core/file_flag';
import { File } from '../core/file';
import { type FileSystem, SynchronousFileSystem } from '../core/filesystem';
import { ApiError, ErrorCode } from '../core/ApiError';
import { File, FileFlag } from '../core/file';
import Stats from '../core/stats';
import PreloadFile from '../generic/preload_file';
import * as path from 'path';
Expand Down
9 changes: 4 additions & 5 deletions src/backend/Dropbox.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import PreloadFile from '../generic/preload_file';
import { BaseFileSystem, type FileSystem } from '../core/file_system';
import { FileFlag } from '../core/file_flag';
import { BaseFileSystem, type FileSystem } from '../core/filesystem';
import { default as Stats, FileType } from '../core/stats';
import { ApiError, ErrorCode } from '../core/api_error';
import { File } from '../core/file';
import { wait } from '../core/util';
import { ApiError, ErrorCode } from '../core/ApiError';
import { File, FileFlag } from '../core/file';
import { wait } from '../core/utils';
import type * as DropboxTypes from 'dropbox';
import { dirname } from 'path';
import Cred from '../core/cred';
Expand Down
7 changes: 3 additions & 4 deletions src/backend/Emscripten.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { SynchronousFileSystem } from '../core/file_system';
import { SynchronousFileSystem } from '../core/filesystem';
import { default as Stats, FileType } from '../core/stats';
import { FileFlag } from '../core/file_flag';
import { BaseFile, File } from '../core/file';
import { ApiError, ErrorCode, ErrorStrings } from '../core/api_error';
import { BaseFile, File, FileFlag } from '../core/file';
import { ApiError, ErrorCode, ErrorStrings } from '../core/ApiError';
import { EmscriptenFSNode } from '../generic/emscripten_fs';
import Cred from '../core/cred';
import { Buffer } from 'buffer';
Expand Down
7 changes: 3 additions & 4 deletions src/backend/FileSystemAccess.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/// <reference lib="dom" />
import { basename, dirname, join } from 'path';
import { ApiError, ErrorCode } from '../core/api_error';
import { ApiError, ErrorCode } from '../core/ApiError';
import Cred from '../core/cred';
import { File } from '../core/file';
import { FileFlag } from '../core/file_flag';
import { BaseFileSystem, type FileSystem } from '../core/file_system';
import { File, FileFlag } from '../core/file';
import { BaseFileSystem, type FileSystem } from '../core/filesystem';
import { default as Stats, FileType } from '../core/stats';
import PreloadFile from '../generic/preload_file';
import { Buffer } from 'buffer';
Expand Down
4 changes: 2 additions & 2 deletions src/backend/FolderAdapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseFileSystem, type FileSystem } from '../core/file_system';
import { BaseFileSystem, type FileSystem } from '../core/filesystem';
import * as path from 'path';
import { ApiError } from '../core/api_error';
import { ApiError } from '../core/ApiError';
import Cred from '../core/cred';
import type { BackendOptions } from '../core/backends';

Expand Down
9 changes: 4 additions & 5 deletions src/backend/HTTPRequest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { BaseFileSystem, type FileSystem, FileContents } from '../core/file_system';
import { ApiError, ErrorCode } from '../core/api_error';
import { FileFlag, ActionType } from '../core/file_flag';
import { copyingSlice } from '../core/util';
import { File } from '../core/file';
import { BaseFileSystem, type FileSystem, FileContents } from '../core/filesystem';
import { ApiError, ErrorCode } from '../core/ApiError';
import { copyingSlice } from '../core/utils';
import { File, FileFlag, ActionType } from '../core/file';
import { default as Stats, FilePerm } from '../core/stats';
import { NoSyncFile } from '../generic/preload_file';
import { fetchIsAvailable, fetchFile, fetchFileSize } from '../generic/fetch';
Expand Down
2 changes: 1 addition & 1 deletion src/backend/IndexedDB.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference lib="dom" />
import { AsyncKeyValueROTransaction, AsyncKeyValueRWTransaction, AsyncKeyValueStore, AsyncKeyValueFileSystem } from '../generic/key_value_filesystem';
import { ApiError, ErrorCode } from '../core/api_error';
import { ApiError, ErrorCode } from '../core/ApiError';
import { Buffer } from 'buffer';
import type { BackendOptions } from '../core/backends';

Expand Down
9 changes: 4 additions & 5 deletions src/backend/IsoFS.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ApiError, ErrorCode } from '../core/api_error';
import { ApiError, ErrorCode } from '../core/ApiError';
import { default as Stats, FileType } from '../core/stats';
import { SynchronousFileSystem, type FileSystem } from '../core/file_system';
import { File } from '../core/file';
import { FileFlag, ActionType } from '../core/file_flag';
import { SynchronousFileSystem, type FileSystem } from '../core/filesystem';
import { File, FileFlag, ActionType } from '../core/file';
import { NoSyncFile } from '../generic/preload_file';
import { copyingSlice, bufferValidator as validator } from '../core/util';
import { copyingSlice, bufferValidator as validator } from '../core/utils';
import * as path from 'path';
import type { Buffer } from 'buffer';
import type { BackendOptions } from '../core/backends';
Expand Down
2 changes: 1 addition & 1 deletion src/backend/LocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SyncKeyValueStore, SimpleSyncStore, SyncKeyValueFileSystem, SimpleSyncRWTransaction, SyncKeyValueRWTransaction } from '../generic/key_value_filesystem';
import { ApiError, ErrorCode } from '../core/api_error';
import { ApiError, ErrorCode } from '../core/ApiError';
import { Buffer } from 'buffer';
import type { BackendOptions } from '../core/backends';

Expand Down
6 changes: 3 additions & 3 deletions src/backend/MountableFileSystem.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type FileSystem, BaseFileSystem } from '../core/file_system';
import { type FileSystem, BaseFileSystem } from '../core/filesystem';
import { InMemoryFileSystem } from './InMemory';
import { ApiError, ErrorCode } from '../core/api_error';
import { ApiError, ErrorCode } from '../core/ApiError';
import fs from '../core/node_fs';
import * as path from 'path';
import { mkdirpSync, toPromise } from '../core/util';
import { mkdirpSync, toPromise } from '../core/utils';
import Cred from '../core/cred';
import type { BackendOptions } from '../core/backends';

Expand Down
7 changes: 3 additions & 4 deletions src/backend/OverlayFS.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type FileSystem, BaseFileSystem } from '../core/file_system';
import { ApiError, ErrorCode } from '../core/api_error';
import { FileFlag, ActionType } from '../core/file_flag';
import { File } from '../core/file';
import { type FileSystem, BaseFileSystem } from '../core/filesystem';
import { ApiError, ErrorCode } from '../core/ApiError';
import { File, FileFlag, ActionType } from '../core/file';
import { default as Stats } from '../core/stats';
import PreloadFile from '../generic/preload_file';
import LockedFS from '../generic/locked_fs';
Expand Down
7 changes: 3 additions & 4 deletions src/backend/WorkerFS.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { type FileSystem, BaseFileSystem, FileContents } from '../core/file_system';
import { ApiError, ErrorCode } from '../core/api_error';
import { FileFlag } from '../core/file_flag';
import { File } from '../core/file';
import { type FileSystem, BaseFileSystem, FileContents } from '../core/filesystem';
import { ApiError, ErrorCode } from '../core/ApiError';
import { File, FileFlag } from '../core/file';
import { default as Stats } from '../core/stats';
import Cred from '../core/cred';
import type { BackendOptions } from '../core/backends';
Expand Down
147 changes: 140 additions & 7 deletions src/backend/ZipFS.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,149 @@
import { ApiError, ErrorCode } from '../core/api_error';
import { ApiError, ErrorCode } from '../core/ApiError';
import { default as Stats, FileType } from '../core/stats';
import { SynchronousFileSystem, type FileSystem } from '../core/file_system';
import { File } from '../core/file';
import { FileFlag, ActionType } from '../core/file_flag';
import { SynchronousFileSystem, type FileSystem } from '../core/filesystem';
import { File, FileFlag, ActionType } from '../core/file';
import { NoSyncFile } from '../generic/preload_file';
import { copyingSlice, bufferValidator } from '../core/util';
import ExtendedASCII from '../generic/extended_ascii';
import { copyingSlice, bufferValidator } from '../core/utils';
import { inflateRawSync } from 'zlib';
import { FileIndex, DirInode, FileInode, isDirInode, isFileInode } from '../generic/file_index';
import type { Buffer } from 'buffer';
import type { BackendOptions } from '../core/backends';

/**
* 8-bit ASCII with the extended character set. Unlike regular ASCII, we do not mask the high bits.
* @see http://en.wikipedia.org/wiki/Extended_ASCII
*/
const extendedASCIIChars = [
'\u00C7',
'\u00FC',
'\u00E9',
'\u00E2',
'\u00E4',
'\u00E0',
'\u00E5',
'\u00E7',
'\u00EA',
'\u00EB',
'\u00E8',
'\u00EF',
'\u00EE',
'\u00EC',
'\u00C4',
'\u00C5',
'\u00C9',
'\u00E6',
'\u00C6',
'\u00F4',
'\u00F6',
'\u00F2',
'\u00FB',
'\u00F9',
'\u00FF',
'\u00D6',
'\u00DC',
'\u00F8',
'\u00A3',
'\u00D8',
'\u00D7',
'\u0192',
'\u00E1',
'\u00ED',
'\u00F3',
'\u00FA',
'\u00F1',
'\u00D1',
'\u00AA',
'\u00BA',
'\u00BF',
'\u00AE',
'\u00AC',
'\u00BD',
'\u00BC',
'\u00A1',
'\u00AB',
'\u00BB',
'_',
'_',
'_',
'\u00A6',
'\u00A6',
'\u00C1',
'\u00C2',
'\u00C0',
'\u00A9',
'\u00A6',
'\u00A6',
'+',
'+',
'\u00A2',
'\u00A5',
'+',
'+',
'-',
'-',
'+',
'-',
'+',
'\u00E3',
'\u00C3',
'+',
'+',
'-',
'-',
'\u00A6',
'-',
'+',
'\u00A4',
'\u00F0',
'\u00D0',
'\u00CA',
'\u00CB',
'\u00C8',
'i',
'\u00CD',
'\u00CE',
'\u00CF',
'+',
'+',
'_',
'_',
'\u00A6',
'\u00CC',
'_',
'\u00D3',
'\u00DF',
'\u00D4',
'\u00D2',
'\u00F5',
'\u00D5',
'\u00B5',
'\u00FE',
'\u00DE',
'\u00DA',
'\u00DB',
'\u00D9',
'\u00FD',
'\u00DD',
'\u00AF',
'\u00B4',
'\u00AD',
'\u00B1',
'_',
'\u00BE',
'\u00B6',
'\u00A7',
'\u00F7',
'\u00B8',
'\u00B0',
'\u00A8',
'\u00B7',
'\u00B9',
'\u00B3',
'\u00B2',
'_',
' ',
];

/**
* Maps CompressionMethod => function that decompresses.
* @hidden
Expand Down Expand Up @@ -99,7 +232,7 @@ function safeToString(buff: Buffer, useUTF8: boolean, start: number, length: num
} else if (useUTF8) {
return buff.toString('utf8', start, start + length);
} else {
return ExtendedASCII.byte2str(buff.subarray(start, start + length));
return [...buff].map(char => (char > 0x7f ? extendedASCIIChars[char - 128] : String.fromCharCode(char))).join();
}
}

Expand Down
File renamed without changes.
Loading

0 comments on commit 51233a1

Please sign in to comment.