1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

scanner: make 0o prefix the only way to define octals

This commit is contained in:
SleepyRoy
2020-02-24 06:43:04 +08:00
committed by GitHub
parent 9d2a60bb11
commit 7d2eb4f604
7 changed files with 50 additions and 10 deletions

View File

@@ -290,13 +290,13 @@ pub fn open_file(path string, mode string, options ...int) ?File {
}
}
mut permission := 0666
mut permission := 0o666
if options.len > 0 {
permission = options[0]
}
$if windows {
if permission < 0600 {
if permission < 0o600 {
permission = 0x0100
}
else {

View File

@@ -33,11 +33,11 @@ fn test_unsetenv() {
fn test_open_file() {
filename := './test1.txt'
hello := 'hello world!'
os.open_file(filename, "r+", 0666) or {
os.open_file(filename, "r+", 0o666) or {
assert err == "No such file or directory"
}
mut file := os.open_file(filename, "w+", 0666) or { panic(err) }
mut file := os.open_file(filename, "w+", 0o666) or { panic(err) }
file.write(hello)
file.close()
@@ -278,11 +278,11 @@ fn test_is_executable_writable_readable() {
f.close()
$if !windows {
os.chmod(file_name, 0600) // mark as readable && writable, but NOT executable
os.chmod(file_name, 0o600) // mark as readable && writable, but NOT executable
assert os.is_writable(file_name)
assert os.is_readable(file_name)
assert !os.is_executable(file_name)
os.chmod(file_name, 0700) // mark as executable too
os.chmod(file_name, 0o700) // mark as executable too
assert os.is_executable(file_name)
} $else {
assert os.is_writable(file_name)