mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-12 06:18:39 +00:00
More conflicts during rebase
This commit is contained in:
@@ -5,8 +5,8 @@ virtual.Arena usage
|
||||
|
||||
Example:
|
||||
// Source: https://github.com/odin-lang/examples/blob/master/arena_allocator/arena_allocator.odin
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
import "core:fmt"
|
||||
import os "core:os/os2"
|
||||
|
||||
// virtual package implements a multi-purpose arena allocator. If you are on a
|
||||
// platform that does not support virtual memory, then there is also a similar
|
||||
@@ -26,14 +26,14 @@ Example:
|
||||
// See arena_init_buffer for an arena that does not use virtual memory,
|
||||
// instead it relies on you feeding it a buffer.
|
||||
|
||||
f1, f1_ok := os.read_entire_file("file1.txt", arena_alloc)
|
||||
ensure(f1_ok)
|
||||
f1, f1_err := os.read_entire_file("file1.txt", arena_alloc)
|
||||
ensure(f1_err == nil)
|
||||
|
||||
f2, f2_ok := os.read_entire_file("file2.txt", arena_alloc)
|
||||
ensure(f2_ok)
|
||||
f2, f2_err := os.read_entire_file("file2.txt", arena_alloc)
|
||||
ensure(f2_err == nil)
|
||||
|
||||
f3, f3_ok := os.read_entire_file("file3.txt", arena_alloc)
|
||||
ensure(f3_ok)
|
||||
f3, f3_err := os.read_entire_file("file3.txt", arena_alloc)
|
||||
ensure(f3_err == nil)
|
||||
|
||||
res := make([]string, 3, arena_alloc)
|
||||
res[0] = string(f1)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package odin_parser
|
||||
|
||||
import "core:odin/tokenizer"
|
||||
import "core:odin/ast"
|
||||
import "core:path/filepath"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
import "core:slice"
|
||||
import "core:strings"
|
||||
import "core:odin/tokenizer"
|
||||
import "core:odin/ast"
|
||||
import "core:path/filepath"
|
||||
import "core:fmt"
|
||||
import os "core:os/os2"
|
||||
import "core:slice"
|
||||
import "core:strings"
|
||||
|
||||
collect_package :: proc(path: string) -> (pkg: ^ast.Package, success: bool) {
|
||||
NO_POS :: tokenizer.Pos{}
|
||||
@@ -28,14 +28,13 @@ collect_package :: proc(path: string) -> (pkg: ^ast.Package, success: bool) {
|
||||
pkg.fullpath = pkg_path
|
||||
|
||||
for match in matches {
|
||||
src: []byte
|
||||
fullpath, ok := filepath.abs(match)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
src, ok = os.read_entire_file(fullpath)
|
||||
if !ok {
|
||||
src, src_err := os.read_entire_file(fullpath, context.allocator)
|
||||
if src_err != nil {
|
||||
delete(fullpath)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
#+build !js
|
||||
package filepath
|
||||
|
||||
import "core:os"
|
||||
import "core:slice"
|
||||
import "core:strings"
|
||||
import "core:unicode/utf8"
|
||||
import os "core:os/os2"
|
||||
import "core:slice"
|
||||
import "core:strings"
|
||||
import "core:unicode/utf8"
|
||||
|
||||
Match_Error :: enum {
|
||||
None,
|
||||
@@ -286,28 +286,23 @@ _glob :: proc(dir, pattern: string, matches: ^[dynamic]string, allocator := cont
|
||||
defer os.close(d)
|
||||
|
||||
{
|
||||
file_info, ferr := os.fstat(d)
|
||||
defer os.file_info_delete(file_info)
|
||||
file_info, ferr := os.fstat(d, allocator)
|
||||
defer os.file_info_delete(file_info, allocator)
|
||||
|
||||
if ferr != nil {
|
||||
return
|
||||
}
|
||||
if !file_info.is_dir {
|
||||
if file_info.type != .Directory {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fis, _ := os.read_dir(d, -1)
|
||||
fis, _ := os.read_dir(d, -1, allocator)
|
||||
slice.sort_by(fis, proc(a, b: os.File_Info) -> bool {
|
||||
return a.name < b.name
|
||||
})
|
||||
defer {
|
||||
for fi in fis {
|
||||
os.file_info_delete(fi)
|
||||
}
|
||||
delete(fis)
|
||||
}
|
||||
defer os.file_info_slice_delete(fis, allocator)
|
||||
|
||||
for fi in fis {
|
||||
n := fi.name
|
||||
@@ -359,4 +354,4 @@ clean_glob_path_windows :: proc(path: string, temp_buf: []byte) -> (prefix_len:
|
||||
vol_len = len(path) -1
|
||||
}
|
||||
return vol_len, path[:len(path)-1]
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package filepath
|
||||
|
||||
import "core:strings"
|
||||
import "base:runtime"
|
||||
import "core:os"
|
||||
import win32 "core:sys/windows"
|
||||
import "core:strings"
|
||||
import "base:runtime"
|
||||
import os "core:os/os2"
|
||||
|
||||
SEPARATOR :: '\\'
|
||||
SEPARATOR_STRING :: `\`
|
||||
@@ -33,53 +32,12 @@ is_UNC :: proc(path: string) -> bool {
|
||||
}
|
||||
|
||||
is_abs :: proc(path: string) -> bool {
|
||||
if is_reserved_name(path) {
|
||||
return true
|
||||
}
|
||||
if len(path) > 0 && is_slash(path[0]) {
|
||||
return true
|
||||
}
|
||||
l := volume_name_len(path)
|
||||
if l == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
path := path
|
||||
path = path[l:]
|
||||
if path == "" {
|
||||
return false
|
||||
}
|
||||
return is_slash(path[0])
|
||||
}
|
||||
|
||||
@(private)
|
||||
temp_full_path :: proc(name: string) -> (path: string, err: os.Error) {
|
||||
ta := context.temp_allocator
|
||||
|
||||
name := name
|
||||
if name == "" {
|
||||
name = "."
|
||||
}
|
||||
|
||||
p := win32.utf8_to_utf16(name, ta)
|
||||
n := win32.GetFullPathNameW(cstring16(raw_data(p)), 0, nil, nil)
|
||||
if n == 0 {
|
||||
return "", os.get_last_error()
|
||||
}
|
||||
|
||||
buf := make([]u16, n, ta)
|
||||
n = win32.GetFullPathNameW(cstring16(raw_data(p)), u32(len(buf)), cstring16(raw_data(buf)), nil)
|
||||
if n == 0 {
|
||||
delete(buf)
|
||||
return "", os.get_last_error()
|
||||
}
|
||||
|
||||
return win32.utf16_to_utf8(buf[:n], ta)
|
||||
return os.is_absolute_path(path)
|
||||
}
|
||||
|
||||
abs :: proc(path: string, allocator := context.allocator) -> (string, bool) {
|
||||
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD(ignore = allocator == context.temp_allocator)
|
||||
full_path, err := temp_full_path(path)
|
||||
full_path, err := os.get_absolute_path(path, context.temp_allocator)
|
||||
if err != nil {
|
||||
return "", false
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
#+build !js
|
||||
package filepath
|
||||
|
||||
import "core:os"
|
||||
import "core:slice"
|
||||
import os "core:os/os2"
|
||||
import "core:slice"
|
||||
|
||||
// Walk_Proc is the type of the procedure called for each file or directory visited by 'walk'
|
||||
// The 'path' parameter contains the parameter to walk as a prefix (this is the same as info.fullpath except on 'root')
|
||||
@@ -40,7 +40,7 @@ walk :: proc(root: string, walk_proc: Walk_Proc, user_data: rawptr) -> os.Error
|
||||
|
||||
@(private)
|
||||
_walk :: proc(info: os.File_Info, walk_proc: Walk_Proc, user_data: rawptr) -> (err: os.Error, skip_dir: bool) {
|
||||
if !info.is_dir {
|
||||
if info.type != .Directory {
|
||||
if info.fullpath == "" && info.name == "" {
|
||||
// ignore empty things
|
||||
return
|
||||
@@ -62,7 +62,7 @@ _walk :: proc(info: os.File_Info, walk_proc: Walk_Proc, user_data: rawptr) -> (e
|
||||
for fi in fis {
|
||||
err, skip_dir = _walk(fi, walk_proc, user_data)
|
||||
if err != nil || skip_dir {
|
||||
if !fi.is_dir || !skip_dir {
|
||||
if fi.type != .Directory || !skip_dir {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user