Skip to content
← Back

src/syntax/process/source_core_file_system.ghul

1
@@IF.not.dotnet()
2
3
// The part of System.IO.Abstractions' file system that EXPAND_NAMESPACES
4
// reads, for a build of the compiler with no .NET library to supply it:
5
// the real file system, through the core library's IO.
6
namespace Syntax.Process is
7
use IO.Path
8
use IO.File
9
use IO.Directory
10
11
class SOURCE_CORE_FILE_SYSTEM is
12
path: SOURCE_CORE_PATH_ACCESS => SOURCE_CORE_PATH_ACCESS()
13
directory: SOURCE_CORE_DIRECTORY_ACCESS => SOURCE_CORE_DIRECTORY_ACCESS()
14
directory_info: SOURCE_CORE_DIRECTORY_INFO_FACTORY => SOURCE_CORE_DIRECTORY_INFO_FACTORY()
15
file: SOURCE_CORE_FILE_ACCESS => SOURCE_CORE_FILE_ACCESS()
16
17
init() is si
18
si
19
20
class SOURCE_CORE_PATH_ACCESS is
21
init() is si
22
23
get_path_root(path: string) -> string? =>
24
if path.starts_with('/') then "/" else "" fi
25
26
get_file_name_without_extension(path: string) -> string? => Path.get_file_name_without_extension(path)
27
28
get_directory_name(path: string) -> string? => Path.get_directory_name(path)
29
30
combine(first: string, second: string) -> string => Path.combine(first, second)
31
si
32
33
class SOURCE_CORE_DIRECTORY_ACCESS is
34
init() is si
35
36
get_current_directory() -> string => Directory.get_current_directory()
37
38
get_files(path: string, pattern: string) -> string[] => Directory.get_files(path, pattern)
39
si
40
41
class SOURCE_CORE_FILE_ACCESS is
42
init() is si
43
44
exists(path: string) -> bool => File.exists(path)
45
si
46
47
class SOURCE_CORE_DIRECTORY_INFO_FACTORY is
48
init() is si
49
50
`new(path: string) -> SOURCE_CORE_DIRECTORY_INFO => SOURCE_CORE_DIRECTORY_INFO(Path.get_full_path(path))
51
si
52
53
class SOURCE_CORE_DIRECTORY_INFO is
54
full_name: string
55
56
init(full_name: string) is
57
self.full_name = full_name
58
si
59
60
name: string => Path.get_file_name(full_name)
61
62
parent: SOURCE_CORE_DIRECTORY_INFO? is
63
if let directory = Path.get_directory_name(full_name) then
64
return SOURCE_CORE_DIRECTORY_INFO(directory)
65
fi
66
67
return null
68
si
69
si
70
si