Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

working on mv command#118

Open
VDozorov wants to merge 56 commits intoWebAssemblyOS:masterfrom
VDozorov:dev-mv
Open

working on mv command#118
VDozorov wants to merge 56 commits intoWebAssemblyOS:masterfrom
VDozorov:dev-mv

Conversation

@VDozorov
Copy link

fixes #117

apharms and others added 30 commits April 24, 2019 12:49
mkdir
Fixed to use with new interface.  Also it currently fails and needs to be finished.  Perhaps add a flag argument for how many lines.
mkdir
initial commit
Added "-p"
Also the test file didn't have a newline at the end.
passing second test
word test
@willemneal
Copy link
Contributor

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.

@VDozorov
Copy link
Author

VDozorov commented May 24, 2019

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

@VDozorov
Copy link
Author

"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?

@VDozorov
Copy link
Author

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?

@willemneal
Copy link
Contributor

You have openFile and openDirectory, openFile will return a WasiResult that fails if the path provided points to a directory and vice versa.

@VDozorov
Copy link
Author

But that doesn't seem to be the case with the example 'cp' code, it only used openFile

@willemneal
Copy link
Contributor

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.

let srcString = srcFile.readString().result;
log<string>(srcString);
dstFile.result.writeString(srcString);
if(res.failed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is true then you would have triggered line 24., which should also return early.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Working on 'mv'

6 participants