Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 747 #753

Open
wants to merge 8 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@rscotchmer
Copy link
Contributor

commented Apr 10, 2019

Fixes issue #747 by allowing fs.open flags to be in the form of a string or bitwise number. Adds a single test for creating a file using fsConstants.O_CREAT.

@codecov-io

This comment has been minimized.

Copy link

commented Apr 10, 2019

Codecov Report

Merging #753 into master will decrease coverage by 0.08%.
The diff coverage is 89.47%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #753      +/-   ##
=========================================
- Coverage   86.88%   86.8%   -0.09%     
=========================================
  Files          16      16              
  Lines        1739    1781      +42     
=========================================
+ Hits         1511    1546      +35     
- Misses        228     235       +7
Impacted Files Coverage Δ
src/constants.js 100% <ø> (ø) ⬆️
src/filesystem/implementation.js 84.18% <89.47%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4aae538...cd3abde. Read the comment docs.

@humphd
Copy link
Contributor

left a comment

Nice work on this. After I get my grades submitted, I'll spend some more time on this, but in the meantime, I've left some feedback. I think this is pretty close to be ready.

One thing we could do to shorten the code in implementation.js would be to do the following at the top after Constants is required (~line 8):

const {
  O_RDONLY,
  O_WRONLY,
  O_RDWR,
  O_CREAT,
  O_TRUNC,
  O_APPEND
} = Constants.fsContansts;

Then we can get rid of all the Constants.fsConstants.* when you just want to use something like O_RDONLY. Make sense?

Show resolved Hide resolved src/filesystem/implementation.js Outdated
@@ -1633,6 +1663,7 @@ function validate_file_options(options, enc, fileMode){
}

function open(context, path, flags, mode, callback) {
flags = stringToFlags(flags);

This comment has been minimized.

Copy link
@humphd

humphd Apr 21, 2019

Contributor

Let's move this down to be with the other flags validation happening on 1691

This comment has been minimized.

Copy link
@rscotchmer

rscotchmer May 8, 2019

Author Contributor

I ended up moving that line, along with the validation, up a little further in the function -- flags gets used prior to line 1691, but until this most recent change, wasn't actually validated until that line. I figured it would make more sense to validate them almost immediately, or at least do that before they're used. Thank you for pointing this out, though -- I don't think I would have caught that mistake if it weren't for this suggestion!

@humphd

humphd approved these changes May 9, 2019

Copy link
Contributor

left a comment

I think this looks good, excellent work. I don't have time to test it today, but will try to do so in the next few days, and can likely land it then. The code seems right to me.

Thanks for finishing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.