Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,6 @@
|
|||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
fso.FileExists('input.txt');
|
||||
fso.FileExists('c:/input.txt');
|
||||
fso.FolderExists('docs');
|
||||
fso.FolderExists('c:/docs');
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
(() => {
|
||||
|
||||
// SYSTEM DIRECTORY FUNCTIONS
|
||||
// FOR MAC OS 'JAVASCRIPT FOR AUTOMATION' SCRIPTING -----------------------
|
||||
|
||||
// doesDirectoryExist :: String -> IO Bool
|
||||
const doesDirectoryExist = strPath => {
|
||||
const
|
||||
dm = $.NSFileManager.defaultManager,
|
||||
ref = Ref();
|
||||
return dm
|
||||
.fileExistsAtPathIsDirectory(
|
||||
$(strPath)
|
||||
.stringByStandardizingPath, ref
|
||||
) && ref[0] === 1;
|
||||
};
|
||||
|
||||
// doesFileExist :: String -> Bool
|
||||
const doesFileExist = strPath => {
|
||||
var error = $();
|
||||
return (
|
||||
$.NSFileManager.defaultManager
|
||||
.attributesOfItemAtPathError(
|
||||
$(strPath)
|
||||
.stringByStandardizingPath,
|
||||
error
|
||||
),
|
||||
error.code === undefined
|
||||
);
|
||||
};
|
||||
|
||||
// getCurrentDirectory :: String
|
||||
const getCurrentDirectory = () =>
|
||||
ObjC.unwrap($.NSFileManager.defaultManager.currentDirectoryPath);
|
||||
|
||||
// getFinderDirectory :: String
|
||||
const getFinderDirectory = () =>
|
||||
Application('Finder')
|
||||
.insertionLocation()
|
||||
.url()
|
||||
.slice(7);
|
||||
|
||||
// getHomeDirectory :: String
|
||||
const getHomeDirectory = () =>
|
||||
ObjC.unwrap($.NSHomeDirectory());
|
||||
|
||||
// setCurrentDirectory :: String -> IO ()
|
||||
const setCurrentDirectory = strPath =>
|
||||
$.NSFileManager.defaultManager
|
||||
.changeCurrentDirectoryPath(
|
||||
$(strPath)
|
||||
.stringByStandardizingPath
|
||||
);
|
||||
|
||||
// GENERIC FUNCTIONS FOR THE TEST -----------------------------------------
|
||||
|
||||
// A list of functions applied to a list of arguments
|
||||
// <*> :: [(a -> b)] -> [a] -> [b]
|
||||
const ap = (fs, xs) => //
|
||||
[].concat.apply([], fs.map(f => //
|
||||
[].concat.apply([], xs.map(x => [f(x)]))));
|
||||
|
||||
// show :: a -> String
|
||||
const show = x => JSON.stringify(x, null, 2);
|
||||
|
||||
// TEST -------------------------------------------------------------------
|
||||
return (
|
||||
setCurrentDirectory('~/Desktop'),
|
||||
show(ap(
|
||||
[doesFileExist, doesDirectoryExist],
|
||||
['input.txt', '/input.txt', 'docs', '/docs']
|
||||
))
|
||||
);
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue