Open VDozorov opened 5 years ago
If you now do a pull from this branch you'll get the files that I added, packages/ash/assembly/bin/mv.ts
and packages/ash/assembly/__tests__/mv.spec.ts
This is a copy of cp.ts
, which is a good starting place. You'll need to use fs.delete
and fs.deleteDirectory
. For now just moving files will suffice so you'll really just need to use fs.delete
.
What are the cases (if any) where fs.delete(*source file*) can fail?
Edit: it fails when what's in parenthesis isn't a file and is a file directory, in which case fs.deleteDirectory should be used
"There was a compilation error when trying to create the wasm binary for file: packages/ash/assembly/tests/mv.spec.ts."
This problem only exists when I have my lines added in trying to delete the source file. I've looked at trying to close the file before deleting it but all the syntax is still a little confusing. Is there something else I need to do or is just closing the source file and deleting it fine?
Thought I should do a try-catch block to see if fs.delete fails due to being passed a directory but apparently try-catch isn't supported. How can I test if what's given is a file or directory? Just look at the end of the string?
You have openFile
and openDirectory
, openFile
will return a WasiResult that fails if the path provided points to a directory and vice versa.
But that doesn't seem to be the case with the example 'cp' code, it only used openFile
From above > "For now just moving files will suffice so you'll really just need to use fs.delete." So you only need fs.openFile.
fixes #117