浏览代码

Use long-form names and alias with short-form UNIX-like names

gingerBill 1 年之前
父节点
当前提交
a626adac8e

+ 21 - 15
core/os/os2/file.odin

@@ -156,41 +156,46 @@ read_link :: proc(name: string, allocator: runtime.Allocator) -> (string, Error)
 }
 
 
-chdir :: proc(name: string) -> Error {
+chdir :: change_directory
+change_directory :: proc(name: string) -> Error {
 	return _chdir(name)
 }
 
-chmod :: proc(name: string, mode: File_Mode) -> Error {
+chmod :: change_mode
+change_mode :: proc(name: string, mode: File_Mode) -> Error {
 	return _chmod(name, mode)
 }
-
-chown :: proc(name: string, uid, gid: int) -> Error {
+chown :: change_owner
+change_owner :: proc(name: string, uid, gid: int) -> Error {
 	return _chown(name, uid, gid)
 }
 
-fchdir :: proc(f: ^File) -> Error {
+fchdir :: fchange_directory
+fchange_directory :: proc(f: ^File) -> Error {
 	return _fchdir(f)
 }
-
-fchmod :: proc(f: ^File, mode: File_Mode) -> Error {
+fchmod :: fchange_mode
+fchange_mode :: proc(f: ^File, mode: File_Mode) -> Error {
 	return _fchmod(f, mode)
 }
 
-fchown :: proc(f: ^File, uid, gid: int) -> Error {
+fchown :: fchange_owner
+fchange_owner :: proc(f: ^File, uid, gid: int) -> Error {
 	return _fchown(f, uid, gid)
 }
 
 
-
-lchown :: proc(name: string, uid, gid: int) -> Error {
+lchown :: change_owner_do_not_follow_links
+change_owner_do_not_follow_links :: proc(name: string, uid, gid: int) -> Error {
 	return _lchown(name, uid, gid)
 }
 
-
-chtimes :: proc(name: string, atime, mtime: time.Time) -> Error {
+chtimes :: change_times
+change_times :: proc(name: string, atime, mtime: time.Time) -> Error {
 	return _chtimes(name, atime, mtime)
 }
-fchtimes :: proc(f: ^File, atime, mtime: time.Time) -> Error {
+fchtimes :: fchange_times
+fchange_times :: proc(f: ^File, atime, mtime: time.Time) -> Error {
 	return _fchtimes(f, atime, mtime)
 }
 
@@ -202,7 +207,8 @@ is_file :: proc(path: string) -> bool {
 	return _is_file(path)
 }
 
-is_dir :: proc(path: string) -> bool {
+is_dir :: is_directory
+is_directory :: proc(path: string) -> bool {
 	return _is_dir(path)
 }
 
@@ -213,7 +219,7 @@ copy_file :: proc(dst_path, src_path: string) -> Error {
 
 	info := fstat(src, _file_allocator()) or_return
 	defer file_info_delete(info, _file_allocator())
-	if info.is_dir {
+	if info.is_directory {
 		return .Invalid_File
 	}
 

+ 8 - 1
core/os/os2/file_util.odin

@@ -74,14 +74,21 @@ read_ptr :: proc(f: ^File, data: rawptr, len: int) -> (n: int, err: Error) {
 }
 
 
+read_entire_file :: proc{
+	read_entire_file_from_path,
+	read_entire_file_from_file,
+}
 
-read_entire_file :: proc(name: string, allocator: runtime.Allocator) -> (data: []byte, err: Error) {
+read_entire_file_from_path :: proc(name: string, allocator: runtime.Allocator) -> (data: []byte, err: Error) {
 	f, ferr := open(name)
 	if ferr != nil {
 		return nil, ferr
 	}
 	defer close(f)
+	return read_entire_file_from_file(f, allocator)
+}
 
+read_entire_file_from_file :: proc(f: ^File, allocator: runtime.Allocator) -> (data: []byte, err: Error) {
 	size: int
 	if size64, err := file_size(f); err == nil {
 		if i64(int(size64)) != size64 {

+ 1 - 1
core/os/os2/heap_linux.odin

@@ -200,7 +200,7 @@ _heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
 	case .Free_All:
 		return nil, .Mode_Not_Implemented
 
-	case .Resize:
+	case .Resize, .Resize_Non_Zeroed:
 		if old_memory == nil {
 			return aligned_alloc(size, alignment)
 		}

+ 9 - 5
core/os/os2/path.odin

@@ -9,11 +9,13 @@ is_path_separator :: proc(c: byte) -> bool {
 	return _is_path_separator(c)
 }
 
-mkdir :: proc(name: string, perm: File_Mode) -> Error {
+mkdir :: make_directory
+make_directory :: proc(name: string, perm: File_Mode) -> Error {
 	return _mkdir(name, perm)
 }
 
-mkdir_all :: proc(path: string, perm: File_Mode) -> Error {
+mkdir_all :: make_directory_all
+make_directory_all :: proc(path: string, perm: File_Mode) -> Error {
 	return _mkdir_all(path, perm)
 }
 
@@ -22,10 +24,12 @@ remove_all :: proc(path: string) -> Error {
 }
 
 
-
-getwd :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
+getwd :: get_working_directory
+get_working_directory :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
 	return _getwd(allocator)
 }
-setwd :: proc(dir: string) -> (err: Error) {
+
+setwd :: set_working_directory
+set_working_directory :: proc(dir: string) -> (err: Error) {
 	return _setwd(dir)
 }

+ 2 - 2
core/os/os2/path_windows.odin

@@ -33,7 +33,7 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error {
 
 	dir, err := stat(path, _temp_allocator())
 	if err == nil {
-		if dir.is_dir {
+		if dir.is_directory {
 			return nil
 		}
 		return .Exist
@@ -60,7 +60,7 @@ _mkdir_all :: proc(path: string, perm: File_Mode) -> Error {
 	err = mkdir(path, perm)
 	if err != nil {
 		dir1, err1 := lstat(path, _temp_allocator())
-		if err1 == nil && dir1.is_dir {
+		if err1 == nil && dir1.is_directory {
 			return nil
 		}
 		return err

+ 7 - 6
core/os/os2/stat.odin

@@ -4,11 +4,11 @@ import "core:time"
 import "base:runtime"
 
 File_Info :: struct {
-	fullpath: string,
-	name:     string,
-	size:     i64,
-	mode:     File_Mode,
-	is_dir:   bool,
+	fullpath:          string,
+	name:              string,
+	size:              i64,
+	mode:              File_Mode,
+	is_directory:      bool,
 	creation_time:     time.Time,
 	modification_time: time.Time,
 	access_time:       time.Time,
@@ -33,7 +33,8 @@ stat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
 	return _stat(name, allocator)
 }
 
-lstat :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
+lstat :: stat_do_not_follow_links
+stat_do_not_follow_links :: proc(name: string, allocator: runtime.Allocator) -> (File_Info, Error) {
 	return _lstat(name, allocator)
 }
 

+ 1 - 1
core/os/os2/stat_linux.odin

@@ -101,7 +101,7 @@ _fstat_internal :: proc(fd: int, allocator: runtime.Allocator) -> (File_Info, Er
 		name = "",
 		size = s.size,
 		mode = 0,
-		is_dir = S_ISDIR(s.mode),
+		is_directory = S_ISDIR(s.mode),
 		modification_time = time.Time {s.modified.seconds},
 		access_time = time.Time {s.last_access.seconds},
 		creation_time = time.Time{0}, // regular stat does not provide this

+ 3 - 3
core/os/os2/stat_windows.odin

@@ -228,7 +228,7 @@ _file_info_from_win32_file_attribute_data :: proc(d: ^win32.WIN32_FILE_ATTRIBUTE
 	fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow)
 
 	fi.mode |= _file_mode_from_file_attributes(d.dwFileAttributes, nil, 0)
-	fi.is_dir = fi.mode & File_Mode_Dir != 0
+	fi.is_directory = fi.mode & File_Mode_Dir != 0
 
 	fi.creation_time     = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime))
 	fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime))
@@ -245,7 +245,7 @@ _file_info_from_win32_find_data :: proc(d: ^win32.WIN32_FIND_DATAW, name: string
 	fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow)
 
 	fi.mode |= _file_mode_from_file_attributes(d.dwFileAttributes, nil, 0)
-	fi.is_dir = fi.mode & File_Mode_Dir != 0
+	fi.is_directory = fi.mode & File_Mode_Dir != 0
 
 	fi.creation_time     = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime))
 	fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime))
@@ -282,7 +282,7 @@ _file_info_from_get_file_information_by_handle :: proc(path: string, h: win32.HA
 	fi.size = i64(d.nFileSizeHigh)<<32 + i64(d.nFileSizeLow)
 
 	fi.mode |= _file_mode_from_file_attributes(ti.FileAttributes, h, ti.ReparseTag)
-	fi.is_dir = fi.mode & File_Mode_Dir != 0
+	fi.is_directory = fi.mode & File_Mode_Dir != 0
 
 	fi.creation_time     = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftCreationTime))
 	fi.modification_time = time.unix(0, win32.FILETIME_as_unix_nanoseconds(d.ftLastWriteTime))

+ 5 - 3
core/os/os2/temp_file.odin

@@ -2,14 +2,16 @@ package os2
 
 import "base:runtime"
 
-create_temp :: proc(dir, pattern: string) -> (^File, Error) {
+create_temp_file :: proc(dir, pattern: string) -> (^File, Error) {
 	return _create_temp(dir, pattern)
 }
 
-mkdir_temp :: proc(dir, pattern: string, allocator: runtime.Allocator) -> (string, Error) {
+mkdir_temp :: make_directory_temp
+make_directory_temp :: proc(dir, pattern: string, allocator: runtime.Allocator) -> (string, Error) {
 	return _mkdir_temp(dir, pattern, allocator)
 }
 
-temp_dir :: proc(allocator: runtime.Allocator) -> (string, Error) {
+temp_dir :: temp_directory
+temp_directory :: proc(allocator: runtime.Allocator) -> (string, Error) {
 	return _temp_dir(allocator)
 }