mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
os: add os.path_devnull
(containing /dev/null on POSIX and \\.\nul on Windows) (#20439)
This commit is contained in:
parent
34da4c97ea
commit
252540a1ea
4 changed files with 38 additions and 3 deletions
|
@ -477,3 +477,18 @@ fn test_open_file_crlf_binary_mode() {
|
|||
|
||||
assert fcont_wb == teststr
|
||||
}
|
||||
|
||||
fn test_path_devnull() {
|
||||
dump(os.path_devnull)
|
||||
content := os.read_file(os.path_devnull)!
|
||||
// dump(content)
|
||||
// dump(content.len)
|
||||
|
||||
os.write_file(os.path_devnull, 'something')!
|
||||
|
||||
content_after := os.read_file(os.path_devnull)!
|
||||
// dump(content_after)
|
||||
// dump(content_after.len)
|
||||
assert content.len == 0
|
||||
assert content_after.len == 0
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ $if js_node {
|
|||
|
||||
pub const path_delimiter = get_path_delimiter()
|
||||
pub const path_separator = get_path_separator()
|
||||
pub const path_devnull = '/dev/null' // TODO
|
||||
|
||||
pub const args = []string{}
|
||||
|
||||
const executable_suffixes = ['']
|
||||
|
|
|
@ -9,9 +9,18 @@ import strings
|
|||
#include <sys/types.h>
|
||||
#include <utime.h>
|
||||
|
||||
// path_separator is the platform specific separator string, used between the folders
|
||||
// and filenames in a path. It is '/' on POSIX, and '\\' on Windows.
|
||||
pub const path_separator = '/'
|
||||
|
||||
// path_delimiter is the platform specific delimiter string, used between the paths
|
||||
// in environment variables like PATH. It is ':' on POSIX, and ';' on Windows.
|
||||
pub const path_delimiter = ':'
|
||||
|
||||
// path_devnull is a platform-specific file path of the null device.
|
||||
// It is '/dev/null' on POSIX, and r'\\.\nul' on Windows.
|
||||
pub const path_devnull = '/dev/null'
|
||||
|
||||
const executable_suffixes = ['']
|
||||
|
||||
const stdin_value = 0
|
||||
|
|
|
@ -6,6 +6,18 @@ import strings
|
|||
#include <process.h>
|
||||
#include <sys/utime.h>
|
||||
|
||||
// path_separator is the platform specific separator string, used between the folders
|
||||
// and filenames in a path. It is '/' on POSIX, and '\\' on Windows.
|
||||
pub const path_separator = '\\'
|
||||
|
||||
// path_delimiter is the platform specific delimiter string, used between the paths
|
||||
// in environment variables like PATH. It is ':' on POSIX, and ';' on Windows.
|
||||
pub const path_delimiter = ';'
|
||||
|
||||
// path_devnull is a platform-specific file path of the null device.
|
||||
// It is '/dev/null' on POSIX, and r'\\.\nul' on Windows.
|
||||
pub const path_devnull = r'\\.\nul'
|
||||
|
||||
// See https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createsymboliclinkw
|
||||
fn C.CreateSymbolicLinkW(&u16, &u16, u32) int
|
||||
|
||||
|
@ -16,9 +28,6 @@ fn C._getpid() int
|
|||
|
||||
const executable_suffixes = ['.exe', '.bat', '.cmd', '']
|
||||
|
||||
pub const path_separator = '\\'
|
||||
pub const path_delimiter = ';'
|
||||
|
||||
// Ref - https://docs.microsoft.com/en-us/windows/desktop/winprog/windows-data-types
|
||||
// A handle to an object.
|
||||
pub type HANDLE = voidptr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue