@duplojs/server 0.0.0-stage → 0.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/_virtual/_rolldown/runtime.cjs +33 -0
- package/dist/_virtual/_rolldown/runtime.mjs +17 -0
- package/dist/command/argument.cjs +27 -0
- package/dist/command/argument.d.ts +18 -0
- package/dist/command/argument.mjs +24 -0
- package/dist/command/create.cjs +102 -0
- package/dist/command/create.d.ts +47 -0
- package/dist/command/create.mjs +96 -0
- package/dist/command/error.cjs +206 -0
- package/dist/command/error.d.ts +61 -0
- package/dist/command/error.mjs +193 -0
- package/dist/command/exec.cjs +19 -0
- package/dist/command/exec.d.ts +14 -0
- package/dist/command/exec.mjs +17 -0
- package/dist/command/execOptions.cjs +41 -0
- package/dist/command/execOptions.d.ts +14 -0
- package/dist/command/execOptions.mjs +37 -0
- package/dist/command/help.cjs +250 -0
- package/dist/command/help.d.ts +10 -0
- package/dist/command/help.mjs +237 -0
- package/dist/command/index.cjs +82 -0
- package/dist/command/index.d.ts +8 -0
- package/dist/command/index.mjs +47 -0
- package/dist/command/kind.cjs +7 -0
- package/dist/command/kind.d.ts +2 -0
- package/dist/command/kind.mjs +5 -0
- package/dist/command/options/base.cjs +76 -0
- package/dist/command/options/base.d.ts +30 -0
- package/dist/command/options/base.mjs +69 -0
- package/dist/command/options/defaults/array.cjs +35 -0
- package/dist/command/options/defaults/array.d.ts +26 -0
- package/dist/command/options/defaults/array.mjs +29 -0
- package/dist/command/options/defaults/boolean.cjs +28 -0
- package/dist/command/options/defaults/boolean.d.ts +14 -0
- package/dist/command/options/defaults/boolean.mjs +25 -0
- package/dist/command/options/defaults/index.d.ts +3 -0
- package/dist/command/options/defaults/simple.cjs +25 -0
- package/dist/command/options/defaults/simple.d.ts +18 -0
- package/dist/command/options/defaults/simple.mjs +22 -0
- package/dist/command/options/identifier.cjs +7 -0
- package/dist/command/options/identifier.d.ts +4 -0
- package/dist/command/options/identifier.mjs +5 -0
- package/dist/command/options/index.d.ts +4 -0
- package/dist/command/options/types/index.d.ts +1 -0
- package/dist/command/options/types/options.d.ts +9 -0
- package/dist/command/types/eligibleType.d.ts +4 -0
- package/dist/command/types/forbiddenDuplicateName.d.ts +11 -0
- package/dist/command/types/forbiddenInvalidIdentifier.d.ts +6 -0
- package/dist/command/types/index.d.ts +3 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.cjs +27 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.d.ts +2 -0
- package/dist/common/environmentVariable/expandEnvironmentVariables.mjs +22 -0
- package/dist/common/environmentVariable/index.cjs +47 -0
- package/dist/common/environmentVariable/index.d.ts +16 -0
- package/dist/common/environmentVariable/index.mjs +41 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.cjs +13 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.d.ts +3 -0
- package/dist/common/environmentVariable/overrideEnvironmentVariables.mjs +9 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.cjs +32 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.d.ts +5 -0
- package/dist/common/environmentVariable/parseEnvironmentFiles.mjs +26 -0
- package/dist/common/environmentVariableOrThrow.cjs +23 -0
- package/dist/common/environmentVariableOrThrow.d.ts +12 -0
- package/dist/common/environmentVariableOrThrow.mjs +19 -0
- package/dist/common/exitProcess.cjs +7 -0
- package/dist/common/exitProcess.d.ts +6 -0
- package/dist/common/exitProcess.mjs +8 -0
- package/dist/common/getCurrentWorkDirectory.cjs +15 -0
- package/dist/common/getCurrentWorkDirectory.d.ts +8 -0
- package/dist/common/getCurrentWorkDirectory.mjs +11 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.cjs +25 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.d.ts +8 -0
- package/dist/common/getCurrentWorkDirectoryOrThrow.mjs +20 -0
- package/dist/common/getProcessArguments.cjs +18 -0
- package/dist/common/getProcessArguments.d.ts +6 -0
- package/dist/common/getProcessArguments.mjs +18 -0
- package/dist/common/index.cjs +44 -0
- package/dist/common/index.d.ts +9 -0
- package/dist/common/index.mjs +27 -0
- package/dist/common/meta/getCurrentDirectoryName.cjs +10 -0
- package/dist/common/meta/getCurrentDirectoryName.d.ts +7 -0
- package/dist/common/meta/getCurrentDirectoryName.mjs +7 -0
- package/dist/common/meta/index.d.ts +7 -0
- package/dist/common/setCurrentWorkingDirectory.cjs +11 -0
- package/dist/common/setCurrentWorkingDirectory.d.ts +8 -0
- package/dist/common/setCurrentWorkingDirectory.mjs +9 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.cjs +23 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.d.ts +8 -0
- package/dist/common/setCurrentWorkingDirectoryOrThrow.mjs +18 -0
- package/dist/dataStructure/common/codec/defaults/index.d.ts +2 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +25 -0
- package/dist/dataStructure/common/codec/defaults/json.d.ts +9 -0
- package/dist/dataStructure/common/codec/defaults/json.mjs +22 -0
- package/dist/dataStructure/common/codec/defaults/string.cjs +25 -0
- package/dist/dataStructure/common/codec/defaults/string.d.ts +13 -0
- package/dist/dataStructure/common/codec/defaults/string.mjs +22 -0
- package/dist/dataStructure/common/codec/index.d.ts +1 -0
- package/dist/dataStructure/common/error/defaultInterpreter.cjs +29 -0
- package/dist/dataStructure/common/error/defaultInterpreter.d.ts +69 -0
- package/dist/dataStructure/common/error/defaultInterpreter.mjs +26 -0
- package/dist/dataStructure/common/error/index.d.ts +1 -0
- package/dist/dataStructure/common/index.d.ts +2 -0
- package/dist/dataStructure/constraint/fileExist.cjs +19 -0
- package/dist/dataStructure/constraint/fileExist.d.ts +10 -0
- package/dist/dataStructure/constraint/fileExist.mjs +15 -0
- package/dist/dataStructure/constraint/folderExist.cjs +19 -0
- package/dist/dataStructure/constraint/folderExist.d.ts +10 -0
- package/dist/dataStructure/constraint/folderExist.mjs +15 -0
- package/dist/dataStructure/constraint/index.d.ts +5 -0
- package/dist/dataStructure/constraint/mimeType.cjs +18 -0
- package/dist/dataStructure/constraint/mimeType.d.ts +11 -0
- package/dist/dataStructure/constraint/mimeType.mjs +14 -0
- package/dist/dataStructure/constraint/size.cjs +29 -0
- package/dist/dataStructure/constraint/size.d.ts +16 -0
- package/dist/dataStructure/constraint/size.mjs +24 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +12 -0
- package/dist/dataStructure/constraint/types/index.d.ts +1 -0
- package/dist/dataStructure/fundamentalType/file.cjs +11 -0
- package/dist/dataStructure/fundamentalType/file.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/file.mjs +8 -0
- package/dist/dataStructure/fundamentalType/folder.cjs +11 -0
- package/dist/dataStructure/fundamentalType/folder.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/folder.mjs +8 -0
- package/dist/dataStructure/fundamentalType/index.d.ts +3 -0
- package/dist/dataStructure/fundamentalType/types/fundamentalTypes.d.ts +8 -0
- package/dist/dataStructure/fundamentalType/types/index.d.ts +1 -0
- package/dist/dataStructure/helper/file.cjs +10 -0
- package/dist/dataStructure/helper/file.d.ts +3 -0
- package/dist/dataStructure/helper/file.mjs +8 -0
- package/dist/dataStructure/helper/fileExist.cjs +7 -0
- package/dist/dataStructure/helper/fileExist.d.ts +2 -0
- package/dist/dataStructure/helper/fileExist.mjs +7 -0
- package/dist/dataStructure/helper/folder.cjs +10 -0
- package/dist/dataStructure/helper/folder.d.ts +3 -0
- package/dist/dataStructure/helper/folder.mjs +8 -0
- package/dist/dataStructure/helper/folderExist.cjs +7 -0
- package/dist/dataStructure/helper/folderExist.d.ts +2 -0
- package/dist/dataStructure/helper/folderExist.mjs +7 -0
- package/dist/dataStructure/helper/index.d.ts +6 -0
- package/dist/dataStructure/helper/mimeType.cjs +7 -0
- package/dist/dataStructure/helper/mimeType.d.ts +2 -0
- package/dist/dataStructure/helper/mimeType.mjs +7 -0
- package/dist/dataStructure/helper/size.cjs +7 -0
- package/dist/dataStructure/helper/size.d.ts +2 -0
- package/dist/dataStructure/helper/size.mjs +7 -0
- package/dist/dataStructure/index.cjs +83 -0
- package/dist/dataStructure/index.d.ts +6 -0
- package/dist/dataStructure/index.mjs +51 -0
- package/dist/dataStructure/kind.cjs +7 -0
- package/dist/dataStructure/kind.d.ts +2 -0
- package/dist/dataStructure/kind.mjs +5 -0
- package/dist/dataStructure/type/file.cjs +14 -0
- package/dist/dataStructure/type/file.d.ts +11 -0
- package/dist/dataStructure/type/file.mjs +11 -0
- package/dist/dataStructure/type/folder.cjs +14 -0
- package/dist/dataStructure/type/folder.d.ts +11 -0
- package/dist/dataStructure/type/folder.mjs +11 -0
- package/dist/dataStructure/type/index.d.ts +3 -0
- package/dist/dataStructure/type/types/index.d.ts +1 -0
- package/dist/dataStructure/type/types/types.d.ts +8 -0
- package/dist/file/appendFile.cjs +67 -0
- package/dist/file/appendFile.d.ts +43 -0
- package/dist/file/appendFile.mjs +54 -0
- package/dist/file/appendTextFile.cjs +67 -0
- package/dist/file/appendTextFile.d.ts +43 -0
- package/dist/file/appendTextFile.mjs +54 -0
- package/dist/file/copy.cjs +53 -0
- package/dist/file/copy.d.ts +43 -0
- package/dist/file/copy.mjs +40 -0
- package/dist/file/createEntryInterface.cjs +19 -0
- package/dist/file/createEntryInterface.d.ts +3 -0
- package/dist/file/createEntryInterface.mjs +15 -0
- package/dist/file/ensureDirectory.cjs +52 -0
- package/dist/file/ensureDirectory.d.ts +36 -0
- package/dist/file/ensureDirectory.mjs +41 -0
- package/dist/file/ensureFile.cjs +60 -0
- package/dist/file/ensureFile.d.ts +39 -0
- package/dist/file/ensureFile.mjs +48 -0
- package/dist/file/exists.cjs +43 -0
- package/dist/file/exists.d.ts +27 -0
- package/dist/file/exists.mjs +35 -0
- package/dist/file/fileInterface.cjs +76 -0
- package/dist/file/fileInterface.d.ts +31 -0
- package/dist/file/fileInterface.mjs +70 -0
- package/dist/file/folderInterface.cjs +76 -0
- package/dist/file/folderInterface.d.ts +33 -0
- package/dist/file/folderInterface.mjs +70 -0
- package/dist/file/index.cjs +634 -0
- package/dist/file/index.d.ts +35 -0
- package/dist/file/index.mjs +335 -0
- package/dist/file/link.cjs +70 -0
- package/dist/file/link.d.ts +46 -0
- package/dist/file/link.mjs +56 -0
- package/dist/file/linkStat.cjs +98 -0
- package/dist/file/linkStat.d.ts +31 -0
- package/dist/file/linkStat.mjs +88 -0
- package/dist/file/makeDirectory.cjs +60 -0
- package/dist/file/makeDirectory.d.ts +45 -0
- package/dist/file/makeDirectory.mjs +47 -0
- package/dist/file/makeTemporaryDirectory.cjs +48 -0
- package/dist/file/makeTemporaryDirectory.d.ts +32 -0
- package/dist/file/makeTemporaryDirectory.mjs +38 -0
- package/dist/file/makeTemporaryFile.cjs +62 -0
- package/dist/file/makeTemporaryFile.d.ts +36 -0
- package/dist/file/makeTemporaryFile.mjs +50 -0
- package/dist/file/move.cjs +71 -0
- package/dist/file/move.d.ts +46 -0
- package/dist/file/move.mjs +57 -0
- package/dist/file/readDirectory.cjs +44 -0
- package/dist/file/readDirectory.d.ts +35 -0
- package/dist/file/readDirectory.mjs +33 -0
- package/dist/file/readFile.cjs +51 -0
- package/dist/file/readFile.d.ts +33 -0
- package/dist/file/readFile.mjs +41 -0
- package/dist/file/readJsonFile.cjs +51 -0
- package/dist/file/readJsonFile.d.ts +33 -0
- package/dist/file/readJsonFile.mjs +41 -0
- package/dist/file/readLink.cjs +46 -0
- package/dist/file/readLink.d.ts +30 -0
- package/dist/file/readLink.mjs +37 -0
- package/dist/file/readTextFile.cjs +51 -0
- package/dist/file/readTextFile.d.ts +33 -0
- package/dist/file/readTextFile.mjs +41 -0
- package/dist/file/realPath.cjs +42 -0
- package/dist/file/realPath.d.ts +27 -0
- package/dist/file/realPath.mjs +34 -0
- package/dist/file/relocate.cjs +83 -0
- package/dist/file/relocate.d.ts +46 -0
- package/dist/file/relocate.mjs +68 -0
- package/dist/file/remove.cjs +60 -0
- package/dist/file/remove.d.ts +42 -0
- package/dist/file/remove.mjs +48 -0
- package/dist/file/rename.cjs +83 -0
- package/dist/file/rename.d.ts +46 -0
- package/dist/file/rename.mjs +68 -0
- package/dist/file/setMode.cjs +65 -0
- package/dist/file/setMode.d.ts +45 -0
- package/dist/file/setMode.mjs +56 -0
- package/dist/file/setOwner.cjs +53 -0
- package/dist/file/setOwner.d.ts +35 -0
- package/dist/file/setOwner.mjs +44 -0
- package/dist/file/setTime.cjs +55 -0
- package/dist/file/setTime.d.ts +36 -0
- package/dist/file/setTime.mjs +45 -0
- package/dist/file/stat.cjs +99 -0
- package/dist/file/stat.d.ts +62 -0
- package/dist/file/stat.mjs +89 -0
- package/dist/file/symlink.cjs +64 -0
- package/dist/file/symlink.d.ts +48 -0
- package/dist/file/symlink.mjs +52 -0
- package/dist/file/truncate.cjs +60 -0
- package/dist/file/truncate.d.ts +42 -0
- package/dist/file/truncate.mjs +47 -0
- package/dist/file/unknownEntryInterface.cjs +40 -0
- package/dist/file/unknownEntryInterface.d.ts +17 -0
- package/dist/file/unknownEntryInterface.mjs +35 -0
- package/dist/file/walkDirectory.cjs +57 -0
- package/dist/file/walkDirectory.d.ts +37 -0
- package/dist/file/walkDirectory.mjs +45 -0
- package/dist/file/writeFile.cjs +68 -0
- package/dist/file/writeFile.d.ts +43 -0
- package/dist/file/writeFile.mjs +55 -0
- package/dist/file/writeJsonFile.cjs +77 -0
- package/dist/file/writeJsonFile.d.ts +46 -0
- package/dist/file/writeJsonFile.mjs +64 -0
- package/dist/file/writeTextFile.cjs +68 -0
- package/dist/file/writeTextFile.d.ts +43 -0
- package/dist/file/writeTextFile.mjs +55 -0
- package/dist/implementor.cjs +67 -0
- package/dist/implementor.d.ts +35 -0
- package/dist/implementor.mjs +55 -0
- package/dist/index.cjs +76 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.mjs +15 -0
- package/dist/kind.cjs +7 -0
- package/dist/kind.d.ts +2 -0
- package/dist/kind.mjs +5 -0
- package/dist/override.d.ts +8 -0
- package/package.json +81 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
5
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
6
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
7
|
+
//#region scripts/file/setOwner.ts
|
|
8
|
+
var SetOwnerErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-owner-not-found", Error) {};
|
|
9
|
+
var SetOwnerErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-owner-permission-denied", Error) {};
|
|
10
|
+
var SetOwnerErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-owner-not-directory", Error) {};
|
|
11
|
+
var SetOwnerErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-owner-read-only", Error) {};
|
|
12
|
+
var SetOwnerErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-owner-invalid-argument", Error) {};
|
|
13
|
+
var SetOwnerError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-owner-error", Error) {};
|
|
14
|
+
function handleNodeSetOwnerError(error) {
|
|
15
|
+
let setOwnerError = void 0;
|
|
16
|
+
if ("code" in error) {
|
|
17
|
+
if (error.code === "ENOENT") setOwnerError = new SetOwnerErrorNotFound(error);
|
|
18
|
+
else if (error.code === "EACCES" || error.code === "EPERM") setOwnerError = new SetOwnerErrorPermissionDenied(error);
|
|
19
|
+
else if (error.code === "ENOTDIR") setOwnerError = new SetOwnerErrorNotDirectory(error);
|
|
20
|
+
else if (error.code === "EROFS") setOwnerError = new SetOwnerErrorReadOnly(error);
|
|
21
|
+
else if (error.code === "EINVAL") setOwnerError = new SetOwnerErrorInvalidArgument(error);
|
|
22
|
+
}
|
|
23
|
+
if (setOwnerError === void 0) setOwnerError = new SetOwnerError(error);
|
|
24
|
+
return _duplojs_lang_either.left("file-system-set-owner-error", setOwnerError);
|
|
25
|
+
}
|
|
26
|
+
function handleDenoSetOwnerError(error) {
|
|
27
|
+
let setOwnerError = void 0;
|
|
28
|
+
if (error instanceof Deno.errors.NotFound) setOwnerError = new SetOwnerErrorNotFound(error);
|
|
29
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) setOwnerError = new SetOwnerErrorPermissionDenied(error);
|
|
30
|
+
else if (error instanceof Deno.errors.NotADirectory) setOwnerError = new SetOwnerErrorNotDirectory(error);
|
|
31
|
+
else if (error instanceof Deno.errors.InvalidData) setOwnerError = new SetOwnerErrorInvalidArgument(error);
|
|
32
|
+
if (setOwnerError === void 0) setOwnerError = new SetOwnerError(error);
|
|
33
|
+
return _duplojs_lang_either.left("file-system-set-owner-error", setOwnerError);
|
|
34
|
+
}
|
|
35
|
+
const setOwnerImplementation = require_implementor.implementFunction("setOwner", {
|
|
36
|
+
NODE: async (path, { userId, groupId }) => require_implementor.nodeFileSystem.value.chown(path, userId, groupId).then(() => _duplojs_lang_either.right("file-system-set-owner")).catch(handleNodeSetOwnerError),
|
|
37
|
+
DENO: (path, { userId, groupId }) => Deno.chown(path, userId, groupId).then(() => _duplojs_lang_either.right("file-system-set-owner")).catch(handleDenoSetOwnerError)
|
|
38
|
+
});
|
|
39
|
+
function setOwner(...args) {
|
|
40
|
+
if (args.length === 1) {
|
|
41
|
+
const [params] = args;
|
|
42
|
+
return (path) => setOwnerImplementation(path, params);
|
|
43
|
+
}
|
|
44
|
+
return setOwnerImplementation(...args);
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.SetOwnerError = SetOwnerError;
|
|
48
|
+
exports.SetOwnerErrorInvalidArgument = SetOwnerErrorInvalidArgument;
|
|
49
|
+
exports.SetOwnerErrorNotDirectory = SetOwnerErrorNotDirectory;
|
|
50
|
+
exports.SetOwnerErrorNotFound = SetOwnerErrorNotFound;
|
|
51
|
+
exports.SetOwnerErrorPermissionDenied = SetOwnerErrorPermissionDenied;
|
|
52
|
+
exports.SetOwnerErrorReadOnly = SetOwnerErrorReadOnly;
|
|
53
|
+
exports.setOwner = setOwner;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import * as DEither from "@duplojs/lang/either";
|
|
3
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
+
export interface SetOwnerParams {
|
|
5
|
+
userId: number;
|
|
6
|
+
groupId: number;
|
|
7
|
+
}
|
|
8
|
+
declare const SetOwnerErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-owner-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-owner-not-found", unknown>>, unknown>;
|
|
9
|
+
export declare class SetOwnerErrorNotFound extends SetOwnerErrorNotFound_base {
|
|
10
|
+
}
|
|
11
|
+
declare const SetOwnerErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-owner-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-owner-permission-denied", unknown>>, unknown>;
|
|
12
|
+
export declare class SetOwnerErrorPermissionDenied extends SetOwnerErrorPermissionDenied_base {
|
|
13
|
+
}
|
|
14
|
+
declare const SetOwnerErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-owner-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-owner-not-directory", unknown>>, unknown>;
|
|
15
|
+
export declare class SetOwnerErrorNotDirectory extends SetOwnerErrorNotDirectory_base {
|
|
16
|
+
}
|
|
17
|
+
declare const SetOwnerErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-owner-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-owner-read-only", unknown>>, unknown>;
|
|
18
|
+
export declare class SetOwnerErrorReadOnly extends SetOwnerErrorReadOnly_base {
|
|
19
|
+
}
|
|
20
|
+
declare const SetOwnerErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-owner-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-owner-invalid-argument", unknown>>, unknown>;
|
|
21
|
+
export declare class SetOwnerErrorInvalidArgument extends SetOwnerErrorInvalidArgument_base {
|
|
22
|
+
}
|
|
23
|
+
declare const SetOwnerError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-owner-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-owner-error", unknown>>, unknown>;
|
|
24
|
+
export declare class SetOwnerError extends SetOwnerError_base {
|
|
25
|
+
}
|
|
26
|
+
export type SetOwnerErrors = (SetOwnerErrorNotFound | SetOwnerErrorPermissionDenied | SetOwnerErrorNotDirectory | SetOwnerErrorReadOnly | SetOwnerErrorInvalidArgument | SetOwnerError);
|
|
27
|
+
export type SetOwnerResult = (DEither.Right<"file-system-set-owner", void> | DEither.Left<"file-system-set-owner-error", SetOwnerErrors>);
|
|
28
|
+
declare module '../implementor' {
|
|
29
|
+
interface ServerFunction {
|
|
30
|
+
setOwner(path: DPath.AnyPath, params: SetOwnerParams): Promise<SetOwnerResult>;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export declare function setOwner(params: SetOwnerParams): (path: DPath.AnyPath) => Promise<SetOwnerResult>;
|
|
34
|
+
export declare function setOwner(path: DPath.AnyPath, params: SetOwnerParams): Promise<SetOwnerResult>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DEither from "@duplojs/lang/either";
|
|
4
|
+
//#region scripts/file/setOwner.ts
|
|
5
|
+
var SetOwnerErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-set-owner-not-found", Error) {};
|
|
6
|
+
var SetOwnerErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-set-owner-permission-denied", Error) {};
|
|
7
|
+
var SetOwnerErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-set-owner-not-directory", Error) {};
|
|
8
|
+
var SetOwnerErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-set-owner-read-only", Error) {};
|
|
9
|
+
var SetOwnerErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-set-owner-invalid-argument", Error) {};
|
|
10
|
+
var SetOwnerError = class extends DCommon.DuploJSError.parentClass("file-system-set-owner-error", Error) {};
|
|
11
|
+
function handleNodeSetOwnerError(error) {
|
|
12
|
+
let setOwnerError = void 0;
|
|
13
|
+
if ("code" in error) {
|
|
14
|
+
if (error.code === "ENOENT") setOwnerError = new SetOwnerErrorNotFound(error);
|
|
15
|
+
else if (error.code === "EACCES" || error.code === "EPERM") setOwnerError = new SetOwnerErrorPermissionDenied(error);
|
|
16
|
+
else if (error.code === "ENOTDIR") setOwnerError = new SetOwnerErrorNotDirectory(error);
|
|
17
|
+
else if (error.code === "EROFS") setOwnerError = new SetOwnerErrorReadOnly(error);
|
|
18
|
+
else if (error.code === "EINVAL") setOwnerError = new SetOwnerErrorInvalidArgument(error);
|
|
19
|
+
}
|
|
20
|
+
if (setOwnerError === void 0) setOwnerError = new SetOwnerError(error);
|
|
21
|
+
return DEither.left("file-system-set-owner-error", setOwnerError);
|
|
22
|
+
}
|
|
23
|
+
function handleDenoSetOwnerError(error) {
|
|
24
|
+
let setOwnerError = void 0;
|
|
25
|
+
if (error instanceof Deno.errors.NotFound) setOwnerError = new SetOwnerErrorNotFound(error);
|
|
26
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) setOwnerError = new SetOwnerErrorPermissionDenied(error);
|
|
27
|
+
else if (error instanceof Deno.errors.NotADirectory) setOwnerError = new SetOwnerErrorNotDirectory(error);
|
|
28
|
+
else if (error instanceof Deno.errors.InvalidData) setOwnerError = new SetOwnerErrorInvalidArgument(error);
|
|
29
|
+
if (setOwnerError === void 0) setOwnerError = new SetOwnerError(error);
|
|
30
|
+
return DEither.left("file-system-set-owner-error", setOwnerError);
|
|
31
|
+
}
|
|
32
|
+
const setOwnerImplementation = implementFunction("setOwner", {
|
|
33
|
+
NODE: async (path, { userId, groupId }) => nodeFileSystem.value.chown(path, userId, groupId).then(() => DEither.right("file-system-set-owner")).catch(handleNodeSetOwnerError),
|
|
34
|
+
DENO: (path, { userId, groupId }) => Deno.chown(path, userId, groupId).then(() => DEither.right("file-system-set-owner")).catch(handleDenoSetOwnerError)
|
|
35
|
+
});
|
|
36
|
+
function setOwner(...args) {
|
|
37
|
+
if (args.length === 1) {
|
|
38
|
+
const [params] = args;
|
|
39
|
+
return (path) => setOwnerImplementation(path, params);
|
|
40
|
+
}
|
|
41
|
+
return setOwnerImplementation(...args);
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { SetOwnerError, SetOwnerErrorInvalidArgument, SetOwnerErrorNotDirectory, SetOwnerErrorNotFound, SetOwnerErrorPermissionDenied, SetOwnerErrorReadOnly, setOwner };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
5
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
6
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
7
|
+
let _duplojs_lang_chrono = require("@duplojs/lang/chrono");
|
|
8
|
+
_duplojs_lang_chrono = require_runtime.__toESM(_duplojs_lang_chrono, 1);
|
|
9
|
+
//#region scripts/file/setTime.ts
|
|
10
|
+
var SetTimeErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-time-not-found", Error) {};
|
|
11
|
+
var SetTimeErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-time-permission-denied", Error) {};
|
|
12
|
+
var SetTimeErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-time-not-directory", Error) {};
|
|
13
|
+
var SetTimeErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-time-read-only", Error) {};
|
|
14
|
+
var SetTimeErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-time-invalid-argument", Error) {};
|
|
15
|
+
var SetTimeError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-set-time-error", Error) {};
|
|
16
|
+
function handleNodeSetTimeError(error) {
|
|
17
|
+
let setTimeError = void 0;
|
|
18
|
+
if ("code" in error) {
|
|
19
|
+
if (error.code === "ENOENT") setTimeError = new SetTimeErrorNotFound(error);
|
|
20
|
+
else if (error.code === "EACCES" || error.code === "EPERM") setTimeError = new SetTimeErrorPermissionDenied(error);
|
|
21
|
+
else if (error.code === "ENOTDIR") setTimeError = new SetTimeErrorNotDirectory(error);
|
|
22
|
+
else if (error.code === "EROFS") setTimeError = new SetTimeErrorReadOnly(error);
|
|
23
|
+
else if (error.code === "EINVAL") setTimeError = new SetTimeErrorInvalidArgument(error);
|
|
24
|
+
}
|
|
25
|
+
if (setTimeError === void 0) setTimeError = new SetTimeError(error);
|
|
26
|
+
return _duplojs_lang_either.left("file-system-set-time-error", setTimeError);
|
|
27
|
+
}
|
|
28
|
+
function handleDenoSetTimeError(error) {
|
|
29
|
+
let setTimeError = void 0;
|
|
30
|
+
if (error instanceof Deno.errors.NotFound) setTimeError = new SetTimeErrorNotFound(error);
|
|
31
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) setTimeError = new SetTimeErrorPermissionDenied(error);
|
|
32
|
+
else if (error instanceof Deno.errors.NotADirectory) setTimeError = new SetTimeErrorNotDirectory(error);
|
|
33
|
+
else if (error instanceof Deno.errors.InvalidData) setTimeError = new SetTimeErrorInvalidArgument(error);
|
|
34
|
+
if (setTimeError === void 0) setTimeError = new SetTimeError(error);
|
|
35
|
+
return _duplojs_lang_either.left("file-system-set-time-error", setTimeError);
|
|
36
|
+
}
|
|
37
|
+
const setTimeImplementation = require_implementor.implementFunction("setTime", {
|
|
38
|
+
NODE: async (path, { accessTime, modifiedTime }) => require_implementor.nodeFileSystem.value.utimes(path, _duplojs_lang_chrono.toTimestamp(accessTime), _duplojs_lang_chrono.toTimestamp(modifiedTime)).then(() => _duplojs_lang_either.right("file-system-set-time")).catch(handleNodeSetTimeError),
|
|
39
|
+
DENO: (path, { accessTime, modifiedTime }) => Deno.utime(path, _duplojs_lang_chrono.toTimestamp(accessTime), _duplojs_lang_chrono.toTimestamp(modifiedTime)).then(() => _duplojs_lang_either.right("file-system-set-time")).catch(handleDenoSetTimeError)
|
|
40
|
+
});
|
|
41
|
+
function setTime(...args) {
|
|
42
|
+
if (args.length === 1) {
|
|
43
|
+
const [params] = args;
|
|
44
|
+
return (path) => setTimeImplementation(path, params);
|
|
45
|
+
}
|
|
46
|
+
return setTimeImplementation(...args);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.SetTimeError = SetTimeError;
|
|
50
|
+
exports.SetTimeErrorInvalidArgument = SetTimeErrorInvalidArgument;
|
|
51
|
+
exports.SetTimeErrorNotDirectory = SetTimeErrorNotDirectory;
|
|
52
|
+
exports.SetTimeErrorNotFound = SetTimeErrorNotFound;
|
|
53
|
+
exports.SetTimeErrorPermissionDenied = SetTimeErrorPermissionDenied;
|
|
54
|
+
exports.SetTimeErrorReadOnly = SetTimeErrorReadOnly;
|
|
55
|
+
exports.setTime = setTime;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as DEither from "@duplojs/lang/either";
|
|
2
|
+
import * as DChrono from "@duplojs/lang/chrono";
|
|
3
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
4
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
5
|
+
interface SetTimeParams {
|
|
6
|
+
accessTime: DChrono.TheDate;
|
|
7
|
+
modifiedTime: DChrono.TheDate;
|
|
8
|
+
}
|
|
9
|
+
declare const SetTimeErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-time-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-time-not-found", unknown>>, unknown>;
|
|
10
|
+
export declare class SetTimeErrorNotFound extends SetTimeErrorNotFound_base {
|
|
11
|
+
}
|
|
12
|
+
declare const SetTimeErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-time-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-time-permission-denied", unknown>>, unknown>;
|
|
13
|
+
export declare class SetTimeErrorPermissionDenied extends SetTimeErrorPermissionDenied_base {
|
|
14
|
+
}
|
|
15
|
+
declare const SetTimeErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-time-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-time-not-directory", unknown>>, unknown>;
|
|
16
|
+
export declare class SetTimeErrorNotDirectory extends SetTimeErrorNotDirectory_base {
|
|
17
|
+
}
|
|
18
|
+
declare const SetTimeErrorReadOnly_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-time-read-only", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-time-read-only", unknown>>, unknown>;
|
|
19
|
+
export declare class SetTimeErrorReadOnly extends SetTimeErrorReadOnly_base {
|
|
20
|
+
}
|
|
21
|
+
declare const SetTimeErrorInvalidArgument_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-time-invalid-argument", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-time-invalid-argument", unknown>>, unknown>;
|
|
22
|
+
export declare class SetTimeErrorInvalidArgument extends SetTimeErrorInvalidArgument_base {
|
|
23
|
+
}
|
|
24
|
+
declare const SetTimeError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-set-time-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-set-time-error", unknown>>, unknown>;
|
|
25
|
+
export declare class SetTimeError extends SetTimeError_base {
|
|
26
|
+
}
|
|
27
|
+
export type SetTimeErrors = (SetTimeErrorNotFound | SetTimeErrorPermissionDenied | SetTimeErrorNotDirectory | SetTimeErrorReadOnly | SetTimeErrorInvalidArgument | SetTimeError);
|
|
28
|
+
export type SetTimeResult = (DEither.Right<"file-system-set-time", void> | DEither.Left<"file-system-set-time-error", SetTimeErrors>);
|
|
29
|
+
declare module '../implementor' {
|
|
30
|
+
interface ServerFunction {
|
|
31
|
+
setTime(path: DPath.AnyPath, params: SetTimeParams): Promise<SetTimeResult>;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export declare function setTime(params: SetTimeParams): (path: DPath.AnyPath) => Promise<SetTimeResult>;
|
|
35
|
+
export declare function setTime(path: DPath.AnyPath, params: SetTimeParams): Promise<SetTimeResult>;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DEither from "@duplojs/lang/either";
|
|
4
|
+
import * as DChrono from "@duplojs/lang/chrono";
|
|
5
|
+
//#region scripts/file/setTime.ts
|
|
6
|
+
var SetTimeErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-set-time-not-found", Error) {};
|
|
7
|
+
var SetTimeErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-set-time-permission-denied", Error) {};
|
|
8
|
+
var SetTimeErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-set-time-not-directory", Error) {};
|
|
9
|
+
var SetTimeErrorReadOnly = class extends DCommon.DuploJSError.parentClass("file-system-set-time-read-only", Error) {};
|
|
10
|
+
var SetTimeErrorInvalidArgument = class extends DCommon.DuploJSError.parentClass("file-system-set-time-invalid-argument", Error) {};
|
|
11
|
+
var SetTimeError = class extends DCommon.DuploJSError.parentClass("file-system-set-time-error", Error) {};
|
|
12
|
+
function handleNodeSetTimeError(error) {
|
|
13
|
+
let setTimeError = void 0;
|
|
14
|
+
if ("code" in error) {
|
|
15
|
+
if (error.code === "ENOENT") setTimeError = new SetTimeErrorNotFound(error);
|
|
16
|
+
else if (error.code === "EACCES" || error.code === "EPERM") setTimeError = new SetTimeErrorPermissionDenied(error);
|
|
17
|
+
else if (error.code === "ENOTDIR") setTimeError = new SetTimeErrorNotDirectory(error);
|
|
18
|
+
else if (error.code === "EROFS") setTimeError = new SetTimeErrorReadOnly(error);
|
|
19
|
+
else if (error.code === "EINVAL") setTimeError = new SetTimeErrorInvalidArgument(error);
|
|
20
|
+
}
|
|
21
|
+
if (setTimeError === void 0) setTimeError = new SetTimeError(error);
|
|
22
|
+
return DEither.left("file-system-set-time-error", setTimeError);
|
|
23
|
+
}
|
|
24
|
+
function handleDenoSetTimeError(error) {
|
|
25
|
+
let setTimeError = void 0;
|
|
26
|
+
if (error instanceof Deno.errors.NotFound) setTimeError = new SetTimeErrorNotFound(error);
|
|
27
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) setTimeError = new SetTimeErrorPermissionDenied(error);
|
|
28
|
+
else if (error instanceof Deno.errors.NotADirectory) setTimeError = new SetTimeErrorNotDirectory(error);
|
|
29
|
+
else if (error instanceof Deno.errors.InvalidData) setTimeError = new SetTimeErrorInvalidArgument(error);
|
|
30
|
+
if (setTimeError === void 0) setTimeError = new SetTimeError(error);
|
|
31
|
+
return DEither.left("file-system-set-time-error", setTimeError);
|
|
32
|
+
}
|
|
33
|
+
const setTimeImplementation = implementFunction("setTime", {
|
|
34
|
+
NODE: async (path, { accessTime, modifiedTime }) => nodeFileSystem.value.utimes(path, DChrono.toTimestamp(accessTime), DChrono.toTimestamp(modifiedTime)).then(() => DEither.right("file-system-set-time")).catch(handleNodeSetTimeError),
|
|
35
|
+
DENO: (path, { accessTime, modifiedTime }) => Deno.utime(path, DChrono.toTimestamp(accessTime), DChrono.toTimestamp(modifiedTime)).then(() => DEither.right("file-system-set-time")).catch(handleDenoSetTimeError)
|
|
36
|
+
});
|
|
37
|
+
function setTime(...args) {
|
|
38
|
+
if (args.length === 1) {
|
|
39
|
+
const [params] = args;
|
|
40
|
+
return (path) => setTimeImplementation(path, params);
|
|
41
|
+
}
|
|
42
|
+
return setTimeImplementation(...args);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { SetTimeError, SetTimeErrorInvalidArgument, SetTimeErrorNotDirectory, SetTimeErrorNotFound, SetTimeErrorPermissionDenied, SetTimeErrorReadOnly, setTime };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
5
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
6
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
7
|
+
let _duplojs_lang_chrono = require("@duplojs/lang/chrono");
|
|
8
|
+
_duplojs_lang_chrono = require_runtime.__toESM(_duplojs_lang_chrono, 1);
|
|
9
|
+
//#region scripts/file/stat.ts
|
|
10
|
+
var StatErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-stat-not-found", Error) {};
|
|
11
|
+
var StatErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-stat-permission-denied", Error) {};
|
|
12
|
+
var StatErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-stat-not-directory", Error) {};
|
|
13
|
+
var StatErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-stat-too-many-open-files", Error) {};
|
|
14
|
+
var StatErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-stat-busy", Error) {};
|
|
15
|
+
var StatError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-stat-error", Error) {};
|
|
16
|
+
function handleNodeStatError(error) {
|
|
17
|
+
let statError = void 0;
|
|
18
|
+
if ("code" in error) {
|
|
19
|
+
if (error.code === "ENOENT") statError = new StatErrorNotFound(error);
|
|
20
|
+
else if (error.code === "EACCES" || error.code === "EPERM") statError = new StatErrorPermissionDenied(error);
|
|
21
|
+
else if (error.code === "ENOTDIR") statError = new StatErrorNotDirectory(error);
|
|
22
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") statError = new StatErrorTooManyOpenFiles(error);
|
|
23
|
+
else if (error.code === "EBUSY") statError = new StatErrorBusy(error);
|
|
24
|
+
}
|
|
25
|
+
if (statError === void 0) statError = new StatError(error);
|
|
26
|
+
return _duplojs_lang_either.left("file-system-stat-error", statError);
|
|
27
|
+
}
|
|
28
|
+
function handleDenoStatError(error) {
|
|
29
|
+
let statError = void 0;
|
|
30
|
+
if (error instanceof Deno.errors.NotFound) statError = new StatErrorNotFound(error);
|
|
31
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) statError = new StatErrorPermissionDenied(error);
|
|
32
|
+
else if (error instanceof Deno.errors.NotADirectory) statError = new StatErrorNotDirectory(error);
|
|
33
|
+
else if (error instanceof Deno.errors.Busy) statError = new StatErrorBusy(error);
|
|
34
|
+
if (statError === void 0) statError = new StatError(error);
|
|
35
|
+
return _duplojs_lang_either.left("file-system-stat-error", statError);
|
|
36
|
+
}
|
|
37
|
+
function createStatInfoWithFsSource(source) {
|
|
38
|
+
return {
|
|
39
|
+
isFile: source.isFile(),
|
|
40
|
+
isDirectory: source.isDirectory(),
|
|
41
|
+
isSymlink: source.isSymbolicLink(),
|
|
42
|
+
sizeBytes: source.size,
|
|
43
|
+
modifiedAt: _duplojs_lang_chrono.isSafeTimestamp(source.mtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.mtime) : null,
|
|
44
|
+
accessedAt: _duplojs_lang_chrono.isSafeTimestamp(source.atime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.atime) : null,
|
|
45
|
+
createdAt: _duplojs_lang_chrono.isSafeTimestamp(source.birthtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.birthtime) : null,
|
|
46
|
+
changedAt: _duplojs_lang_chrono.isSafeTimestamp(source.ctime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.ctime) : null,
|
|
47
|
+
deviceId: source.dev,
|
|
48
|
+
inode: source.ino,
|
|
49
|
+
permissionsMode: source.mode,
|
|
50
|
+
hardLinkCount: source.nlink,
|
|
51
|
+
ownerUserId: source.uid,
|
|
52
|
+
ownerGroupId: source.gid,
|
|
53
|
+
specialDeviceId: source.rdev,
|
|
54
|
+
ioBlockSize: source.blksize,
|
|
55
|
+
allocatedBlockCount: source.blocks,
|
|
56
|
+
isBlockDevice: source.isBlockDevice(),
|
|
57
|
+
isCharacterDevice: source.isCharacterDevice(),
|
|
58
|
+
isFifo: source.isFIFO(),
|
|
59
|
+
isSocket: source.isSocket()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function createStatInfoWithDeno(source) {
|
|
63
|
+
return {
|
|
64
|
+
isFile: source.isFile,
|
|
65
|
+
isDirectory: source.isDirectory,
|
|
66
|
+
isSymlink: source.isSymlink,
|
|
67
|
+
sizeBytes: source.size,
|
|
68
|
+
modifiedAt: source.mtime && _duplojs_lang_chrono.isSafeTimestamp(source.mtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.mtime) : null,
|
|
69
|
+
accessedAt: source.atime && _duplojs_lang_chrono.isSafeTimestamp(source.atime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.atime) : null,
|
|
70
|
+
createdAt: source.birthtime && _duplojs_lang_chrono.isSafeTimestamp(source.birthtime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.birthtime) : null,
|
|
71
|
+
changedAt: source.ctime && _duplojs_lang_chrono.isSafeTimestamp(source.ctime.getTime()) ? _duplojs_lang_chrono.createDateOrThrow(source.ctime) : null,
|
|
72
|
+
deviceId: source.dev,
|
|
73
|
+
inode: source.ino,
|
|
74
|
+
permissionsMode: source.mode,
|
|
75
|
+
hardLinkCount: source.nlink,
|
|
76
|
+
ownerUserId: source.uid,
|
|
77
|
+
ownerGroupId: source.gid,
|
|
78
|
+
specialDeviceId: source.rdev,
|
|
79
|
+
ioBlockSize: source.blksize,
|
|
80
|
+
allocatedBlockCount: source.blocks,
|
|
81
|
+
isBlockDevice: source.isBlockDevice,
|
|
82
|
+
isCharacterDevice: source.isCharDevice,
|
|
83
|
+
isFifo: source.isFifo,
|
|
84
|
+
isSocket: source.isSocket
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const stat = require_implementor.implementFunction("stat", {
|
|
88
|
+
NODE: async (path) => require_implementor.nodeFileSystem.value.stat(path).then(_duplojs_lang_common.innerPipe(createStatInfoWithFsSource, (value) => _duplojs_lang_either.right("file-system-stat", value))).catch(handleNodeStatError),
|
|
89
|
+
DENO: (path) => Deno.stat(path).then(_duplojs_lang_common.innerPipe(createStatInfoWithDeno, (value) => _duplojs_lang_either.right("file-system-stat", value))).catch(handleDenoStatError),
|
|
90
|
+
BUN: (path) => Bun.file(path).stat().then(_duplojs_lang_common.innerPipe(createStatInfoWithFsSource, (value) => _duplojs_lang_either.right("file-system-stat", value))).catch(handleNodeStatError)
|
|
91
|
+
});
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.StatError = StatError;
|
|
94
|
+
exports.StatErrorBusy = StatErrorBusy;
|
|
95
|
+
exports.StatErrorNotDirectory = StatErrorNotDirectory;
|
|
96
|
+
exports.StatErrorNotFound = StatErrorNotFound;
|
|
97
|
+
exports.StatErrorPermissionDenied = StatErrorPermissionDenied;
|
|
98
|
+
exports.StatErrorTooManyOpenFiles = StatErrorTooManyOpenFiles;
|
|
99
|
+
exports.stat = stat;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
2
|
+
import type * as DPath from "@duplojs/lang/path";
|
|
3
|
+
import * as DEither from "@duplojs/lang/either";
|
|
4
|
+
import * as DChrono from "@duplojs/lang/chrono";
|
|
5
|
+
export interface StatInfo {
|
|
6
|
+
/** Type of entry */
|
|
7
|
+
isFile: boolean;
|
|
8
|
+
isDirectory: boolean;
|
|
9
|
+
isSymlink: boolean;
|
|
10
|
+
/** Size in bytes */
|
|
11
|
+
sizeBytes: number;
|
|
12
|
+
/** Timestamps */
|
|
13
|
+
modifiedAt: DChrono.TheDate | null;
|
|
14
|
+
accessedAt: DChrono.TheDate | null;
|
|
15
|
+
createdAt: DChrono.TheDate | null;
|
|
16
|
+
changedAt: DChrono.TheDate | null;
|
|
17
|
+
/** Unix/FS identifiers */
|
|
18
|
+
deviceId: number;
|
|
19
|
+
inode: number | null;
|
|
20
|
+
permissionsMode: number | null;
|
|
21
|
+
hardLinkCount: number | null;
|
|
22
|
+
/** Ownership */
|
|
23
|
+
ownerUserId: number | null;
|
|
24
|
+
ownerGroupId: number | null;
|
|
25
|
+
/** Special device id (if file is a device) */
|
|
26
|
+
specialDeviceId: number | null;
|
|
27
|
+
/** FS allocation */
|
|
28
|
+
ioBlockSize: number | null;
|
|
29
|
+
allocatedBlockCount: number | null;
|
|
30
|
+
/** Special file kinds */
|
|
31
|
+
isBlockDevice: boolean | null;
|
|
32
|
+
isCharacterDevice: boolean | null;
|
|
33
|
+
isFifo: boolean | null;
|
|
34
|
+
isSocket: boolean | null;
|
|
35
|
+
}
|
|
36
|
+
declare const StatErrorNotFound_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-stat-not-found", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-stat-not-found", unknown>>, unknown>;
|
|
37
|
+
export declare class StatErrorNotFound extends StatErrorNotFound_base {
|
|
38
|
+
}
|
|
39
|
+
declare const StatErrorPermissionDenied_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-stat-permission-denied", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-stat-permission-denied", unknown>>, unknown>;
|
|
40
|
+
export declare class StatErrorPermissionDenied extends StatErrorPermissionDenied_base {
|
|
41
|
+
}
|
|
42
|
+
declare const StatErrorNotDirectory_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-stat-not-directory", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-stat-not-directory", unknown>>, unknown>;
|
|
43
|
+
export declare class StatErrorNotDirectory extends StatErrorNotDirectory_base {
|
|
44
|
+
}
|
|
45
|
+
declare const StatErrorTooManyOpenFiles_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-stat-too-many-open-files", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-stat-too-many-open-files", unknown>>, unknown>;
|
|
46
|
+
export declare class StatErrorTooManyOpenFiles extends StatErrorTooManyOpenFiles_base {
|
|
47
|
+
}
|
|
48
|
+
declare const StatErrorBusy_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-stat-busy", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-stat-busy", unknown>>, unknown>;
|
|
49
|
+
export declare class StatErrorBusy extends StatErrorBusy_base {
|
|
50
|
+
}
|
|
51
|
+
declare const StatError_base: abstract new (error: Error) => DCommon.DuploJSError<"file-system-stat-error", Error> & import('@duplojs/lang/kind').Kind<import('@duplojs/lang/kind').Handler<import('@duplojs/lang/kind').Definition<"@DuplojsLangCommon/duplojs-error-file-system-stat-error", unknown>>, unknown>;
|
|
52
|
+
export declare class StatError extends StatError_base {
|
|
53
|
+
}
|
|
54
|
+
export type StatErrors = (StatErrorNotFound | StatErrorPermissionDenied | StatErrorNotDirectory | StatErrorTooManyOpenFiles | StatErrorBusy | StatError);
|
|
55
|
+
export type StatResult = (DEither.Right<"file-system-stat", StatInfo> | DEither.Left<"file-system-stat-error", StatErrors>);
|
|
56
|
+
declare module '../implementor' {
|
|
57
|
+
interface ServerFunction {
|
|
58
|
+
stat(path: DPath.AnyPath): Promise<StatResult>;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export declare const stat: (path: DPath.AnyPath) => Promise<StatResult>;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { implementFunction, nodeFileSystem } from "../implementor.mjs";
|
|
2
|
+
import * as DCommon from "@duplojs/lang/common";
|
|
3
|
+
import * as DEither from "@duplojs/lang/either";
|
|
4
|
+
import * as DChrono from "@duplojs/lang/chrono";
|
|
5
|
+
//#region scripts/file/stat.ts
|
|
6
|
+
var StatErrorNotFound = class extends DCommon.DuploJSError.parentClass("file-system-stat-not-found", Error) {};
|
|
7
|
+
var StatErrorPermissionDenied = class extends DCommon.DuploJSError.parentClass("file-system-stat-permission-denied", Error) {};
|
|
8
|
+
var StatErrorNotDirectory = class extends DCommon.DuploJSError.parentClass("file-system-stat-not-directory", Error) {};
|
|
9
|
+
var StatErrorTooManyOpenFiles = class extends DCommon.DuploJSError.parentClass("file-system-stat-too-many-open-files", Error) {};
|
|
10
|
+
var StatErrorBusy = class extends DCommon.DuploJSError.parentClass("file-system-stat-busy", Error) {};
|
|
11
|
+
var StatError = class extends DCommon.DuploJSError.parentClass("file-system-stat-error", Error) {};
|
|
12
|
+
function handleNodeStatError(error) {
|
|
13
|
+
let statError = void 0;
|
|
14
|
+
if ("code" in error) {
|
|
15
|
+
if (error.code === "ENOENT") statError = new StatErrorNotFound(error);
|
|
16
|
+
else if (error.code === "EACCES" || error.code === "EPERM") statError = new StatErrorPermissionDenied(error);
|
|
17
|
+
else if (error.code === "ENOTDIR") statError = new StatErrorNotDirectory(error);
|
|
18
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") statError = new StatErrorTooManyOpenFiles(error);
|
|
19
|
+
else if (error.code === "EBUSY") statError = new StatErrorBusy(error);
|
|
20
|
+
}
|
|
21
|
+
if (statError === void 0) statError = new StatError(error);
|
|
22
|
+
return DEither.left("file-system-stat-error", statError);
|
|
23
|
+
}
|
|
24
|
+
function handleDenoStatError(error) {
|
|
25
|
+
let statError = void 0;
|
|
26
|
+
if (error instanceof Deno.errors.NotFound) statError = new StatErrorNotFound(error);
|
|
27
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) statError = new StatErrorPermissionDenied(error);
|
|
28
|
+
else if (error instanceof Deno.errors.NotADirectory) statError = new StatErrorNotDirectory(error);
|
|
29
|
+
else if (error instanceof Deno.errors.Busy) statError = new StatErrorBusy(error);
|
|
30
|
+
if (statError === void 0) statError = new StatError(error);
|
|
31
|
+
return DEither.left("file-system-stat-error", statError);
|
|
32
|
+
}
|
|
33
|
+
function createStatInfoWithFsSource(source) {
|
|
34
|
+
return {
|
|
35
|
+
isFile: source.isFile(),
|
|
36
|
+
isDirectory: source.isDirectory(),
|
|
37
|
+
isSymlink: source.isSymbolicLink(),
|
|
38
|
+
sizeBytes: source.size,
|
|
39
|
+
modifiedAt: DChrono.isSafeTimestamp(source.mtime.getTime()) ? DChrono.createDateOrThrow(source.mtime) : null,
|
|
40
|
+
accessedAt: DChrono.isSafeTimestamp(source.atime.getTime()) ? DChrono.createDateOrThrow(source.atime) : null,
|
|
41
|
+
createdAt: DChrono.isSafeTimestamp(source.birthtime.getTime()) ? DChrono.createDateOrThrow(source.birthtime) : null,
|
|
42
|
+
changedAt: DChrono.isSafeTimestamp(source.ctime.getTime()) ? DChrono.createDateOrThrow(source.ctime) : null,
|
|
43
|
+
deviceId: source.dev,
|
|
44
|
+
inode: source.ino,
|
|
45
|
+
permissionsMode: source.mode,
|
|
46
|
+
hardLinkCount: source.nlink,
|
|
47
|
+
ownerUserId: source.uid,
|
|
48
|
+
ownerGroupId: source.gid,
|
|
49
|
+
specialDeviceId: source.rdev,
|
|
50
|
+
ioBlockSize: source.blksize,
|
|
51
|
+
allocatedBlockCount: source.blocks,
|
|
52
|
+
isBlockDevice: source.isBlockDevice(),
|
|
53
|
+
isCharacterDevice: source.isCharacterDevice(),
|
|
54
|
+
isFifo: source.isFIFO(),
|
|
55
|
+
isSocket: source.isSocket()
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function createStatInfoWithDeno(source) {
|
|
59
|
+
return {
|
|
60
|
+
isFile: source.isFile,
|
|
61
|
+
isDirectory: source.isDirectory,
|
|
62
|
+
isSymlink: source.isSymlink,
|
|
63
|
+
sizeBytes: source.size,
|
|
64
|
+
modifiedAt: source.mtime && DChrono.isSafeTimestamp(source.mtime.getTime()) ? DChrono.createDateOrThrow(source.mtime) : null,
|
|
65
|
+
accessedAt: source.atime && DChrono.isSafeTimestamp(source.atime.getTime()) ? DChrono.createDateOrThrow(source.atime) : null,
|
|
66
|
+
createdAt: source.birthtime && DChrono.isSafeTimestamp(source.birthtime.getTime()) ? DChrono.createDateOrThrow(source.birthtime) : null,
|
|
67
|
+
changedAt: source.ctime && DChrono.isSafeTimestamp(source.ctime.getTime()) ? DChrono.createDateOrThrow(source.ctime) : null,
|
|
68
|
+
deviceId: source.dev,
|
|
69
|
+
inode: source.ino,
|
|
70
|
+
permissionsMode: source.mode,
|
|
71
|
+
hardLinkCount: source.nlink,
|
|
72
|
+
ownerUserId: source.uid,
|
|
73
|
+
ownerGroupId: source.gid,
|
|
74
|
+
specialDeviceId: source.rdev,
|
|
75
|
+
ioBlockSize: source.blksize,
|
|
76
|
+
allocatedBlockCount: source.blocks,
|
|
77
|
+
isBlockDevice: source.isBlockDevice,
|
|
78
|
+
isCharacterDevice: source.isCharDevice,
|
|
79
|
+
isFifo: source.isFifo,
|
|
80
|
+
isSocket: source.isSocket
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const stat = implementFunction("stat", {
|
|
84
|
+
NODE: async (path) => nodeFileSystem.value.stat(path).then(DCommon.innerPipe(createStatInfoWithFsSource, (value) => DEither.right("file-system-stat", value))).catch(handleNodeStatError),
|
|
85
|
+
DENO: (path) => Deno.stat(path).then(DCommon.innerPipe(createStatInfoWithDeno, (value) => DEither.right("file-system-stat", value))).catch(handleDenoStatError),
|
|
86
|
+
BUN: (path) => Bun.file(path).stat().then(DCommon.innerPipe(createStatInfoWithFsSource, (value) => DEither.right("file-system-stat", value))).catch(handleNodeStatError)
|
|
87
|
+
});
|
|
88
|
+
//#endregion
|
|
89
|
+
export { StatError, StatErrorBusy, StatErrorNotDirectory, StatErrorNotFound, StatErrorPermissionDenied, StatErrorTooManyOpenFiles, stat };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
const require_implementor = require("../implementor.cjs");
|
|
3
|
+
let _duplojs_lang_common = require("@duplojs/lang/common");
|
|
4
|
+
_duplojs_lang_common = require_runtime.__toESM(_duplojs_lang_common, 1);
|
|
5
|
+
let _duplojs_lang_either = require("@duplojs/lang/either");
|
|
6
|
+
_duplojs_lang_either = require_runtime.__toESM(_duplojs_lang_either, 1);
|
|
7
|
+
//#region scripts/file/symlink.ts
|
|
8
|
+
var SymlinkErrorNotFound = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-not-found", Error) {};
|
|
9
|
+
var SymlinkErrorPermissionDenied = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-permission-denied", Error) {};
|
|
10
|
+
var SymlinkErrorAlreadyExists = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-already-exists", Error) {};
|
|
11
|
+
var SymlinkErrorNotDirectory = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-not-directory", Error) {};
|
|
12
|
+
var SymlinkErrorReadOnly = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-read-only", Error) {};
|
|
13
|
+
var SymlinkErrorInvalidArgument = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-invalid-argument", Error) {};
|
|
14
|
+
var SymlinkErrorTooManyOpenFiles = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-too-many-open-files", Error) {};
|
|
15
|
+
var SymlinkErrorBusy = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-busy", Error) {};
|
|
16
|
+
var SymlinkError = class extends _duplojs_lang_common.DuploJSError.parentClass("file-system-symlink-error", Error) {};
|
|
17
|
+
function handleNodeSymlinkError(error) {
|
|
18
|
+
let symlinkError = void 0;
|
|
19
|
+
if ("code" in error) {
|
|
20
|
+
if (error.code === "ENOENT") symlinkError = new SymlinkErrorNotFound(error);
|
|
21
|
+
else if (error.code === "EACCES" || error.code === "EPERM") symlinkError = new SymlinkErrorPermissionDenied(error);
|
|
22
|
+
else if (error.code === "EEXIST") symlinkError = new SymlinkErrorAlreadyExists(error);
|
|
23
|
+
else if (error.code === "ENOTDIR") symlinkError = new SymlinkErrorNotDirectory(error);
|
|
24
|
+
else if (error.code === "EROFS") symlinkError = new SymlinkErrorReadOnly(error);
|
|
25
|
+
else if (error.code === "EINVAL") symlinkError = new SymlinkErrorInvalidArgument(error);
|
|
26
|
+
else if (error.code === "EMFILE" || error.code === "ENFILE") symlinkError = new SymlinkErrorTooManyOpenFiles(error);
|
|
27
|
+
else if (error.code === "EBUSY") symlinkError = new SymlinkErrorBusy(error);
|
|
28
|
+
}
|
|
29
|
+
if (symlinkError === void 0) symlinkError = new SymlinkError(error);
|
|
30
|
+
return _duplojs_lang_either.left("file-system-symlink-error", symlinkError);
|
|
31
|
+
}
|
|
32
|
+
function handleDenoSymlinkError(error) {
|
|
33
|
+
let symlinkError = void 0;
|
|
34
|
+
if (error instanceof Deno.errors.NotFound) symlinkError = new SymlinkErrorNotFound(error);
|
|
35
|
+
else if (error instanceof Deno.errors.PermissionDenied || error instanceof Deno.errors.NotCapable) symlinkError = new SymlinkErrorPermissionDenied(error);
|
|
36
|
+
else if (error instanceof Deno.errors.AlreadyExists) symlinkError = new SymlinkErrorAlreadyExists(error);
|
|
37
|
+
else if (error instanceof Deno.errors.NotADirectory) symlinkError = new SymlinkErrorNotDirectory(error);
|
|
38
|
+
else if (error instanceof Deno.errors.InvalidData) symlinkError = new SymlinkErrorInvalidArgument(error);
|
|
39
|
+
else if (error instanceof Deno.errors.Busy) symlinkError = new SymlinkErrorBusy(error);
|
|
40
|
+
if (symlinkError === void 0) symlinkError = new SymlinkError(error);
|
|
41
|
+
return _duplojs_lang_either.left("file-system-symlink-error", symlinkError);
|
|
42
|
+
}
|
|
43
|
+
const symlinkImplementation = require_implementor.implementFunction("symlink", {
|
|
44
|
+
NODE: async (oldPath, newPath, params) => require_implementor.nodeFileSystem.value.symlink(oldPath, newPath, params?.type).then(() => _duplojs_lang_either.right("file-system-symlink")).catch(handleNodeSymlinkError),
|
|
45
|
+
DENO: (oldPath, newPath, params) => Deno.symlink(oldPath, newPath, params).then(() => _duplojs_lang_either.right("file-system-symlink")).catch(handleDenoSymlinkError)
|
|
46
|
+
});
|
|
47
|
+
function symlink(...args) {
|
|
48
|
+
if (args.length === 1) {
|
|
49
|
+
const [newPath] = args;
|
|
50
|
+
return (oldPath) => symlinkImplementation(oldPath, newPath);
|
|
51
|
+
}
|
|
52
|
+
return symlinkImplementation(...args);
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
exports.SymlinkError = SymlinkError;
|
|
56
|
+
exports.SymlinkErrorAlreadyExists = SymlinkErrorAlreadyExists;
|
|
57
|
+
exports.SymlinkErrorBusy = SymlinkErrorBusy;
|
|
58
|
+
exports.SymlinkErrorInvalidArgument = SymlinkErrorInvalidArgument;
|
|
59
|
+
exports.SymlinkErrorNotDirectory = SymlinkErrorNotDirectory;
|
|
60
|
+
exports.SymlinkErrorNotFound = SymlinkErrorNotFound;
|
|
61
|
+
exports.SymlinkErrorPermissionDenied = SymlinkErrorPermissionDenied;
|
|
62
|
+
exports.SymlinkErrorReadOnly = SymlinkErrorReadOnly;
|
|
63
|
+
exports.SymlinkErrorTooManyOpenFiles = SymlinkErrorTooManyOpenFiles;
|
|
64
|
+
exports.symlink = symlink;
|