-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Implemented deno.chmodSync for mac/linux os users. #673
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as fbs from "gen/msg_generated"; | ||
import { flatbuffers } from "flatbuffers"; | ||
import * as dispatch from "./dispatch"; | ||
/** | ||
* Synchronously changes the file permissions. | ||
* | ||
* import { chmodSync } from "deno"; | ||
* chmodSync(path, mode); | ||
*/ | ||
export function chmodSync(path: string, mode: number): void { | ||
dispatch.sendSync(...req(path, mode)); | ||
} | ||
function req( | ||
path: string, | ||
mode: number | ||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { | ||
const builder = new flatbuffers.Builder(); | ||
const path_ = builder.createString(path); | ||
fbs.Chmod.startChmod(builder); | ||
fbs.Chmod.addPath(builder, path_); | ||
fbs.Chmod.addMode(builder, mode); | ||
const msg = fbs.Chmod.endChmod(builder); | ||
return [builder, fbs.Any.Chmod, msg]; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2018 the Deno authors. All rights reserved. MIT license. | ||
import { test, testPerm, assert, assertEqual } from "./test_util.ts"; | ||
import * as deno from "deno"; | ||
testPerm({ write: true }, function chmodSyncSuccess() { | ||
const enc = new TextEncoder(); | ||
const data = enc.encode("Hello"); | ||
const filename = deno.makeTempDirSync() + "/test.txt"; | ||
deno.writeFileSync(filename, data, 0o666); | ||
let fileInfo = deno.statSync(filename); | ||
console.log(fileInfo.mode, 0o666); // This is printing 33206 438 | ||
deno.chmodSync(filename, 0o777); | ||
fileInfo = deno.statSync(filename); | ||
assertEqual(fileInfo.mode, 0o777); | ||
}); | ||
testPerm({ write: false }, function chmodSyncPerm() { | ||
let err; | ||
try { | ||
const filename = deno.makeTempDirSync() + "/test.txt"; | ||
deno.chmodSync(filename, 0o777); | ||
} catch (e) { | ||
err = e; | ||
} | ||
assertEqual(err.kind, deno.ErrorKind.PermissionDenied); | ||
assertEqual(err.name, "PermissionDenied"); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ry deno.statSync(filename).mode is not working properly.
Checkout the line 802 in the build log Here.
802: 33206 438. This is coming from the line console.log(fileInfo.mode, 0o666); on which I am commenting.
I had initially opened an issue #756. At that time it worked on travis. Now it is not working on travis also. Can you check if you are also having the same behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srijanreddy98 You might want to apply a mask (
0o777
). For example in python