BadScript 2
Loading...
Searching...
No Matches
BadPathApi.cs
Go to the documentation of this file.
1using BadScript2.IO;
2
4
5[BadInteropApi("Path", true)]
6internal partial class BadPathApi
7{
12
13 public BadPathApi(IFileSystem fileSystem) : this()
14 {
15 m_FileSystem = fileSystem;
16 }
17
18 [BadMethod(description: "Returns the file name and extension of the specified path string.")]
19 [return: BadReturn("The characters after the last directory character in path.")]
20 private string GetFileName([BadParameter(description: "The Path to get the file name from.")] string path)
21 {
22 return Path.GetFileName(path);
23 }
24
25 [BadMethod(description: "Returns the file name of the specified path string without the extension")]
26 [return: BadReturn("The string returned by GetFileName(string), minus the last period (.) and all characters following it")]
27 private string GetFileNameWithoutExtension([BadParameter(description: "The Path to get the file name from.")] string path)
28 {
29 return Path.GetFileNameWithoutExtension(path);
30 }
31
32 [BadMethod(description: "Returns the directory information for the specified path string")]
33 [return: BadReturn("Directory information for path, or null if path denotes a root directory or is null. Returns Empty if path does not contain directory information.")]
34 private string? GetDirectoryName([BadParameter(description: "The path of a file or directory.")] string path)
35 {
36 return Path.GetDirectoryName(path);
37 }
38
39 [BadMethod(description: "Returns the extension of the specified path string.")]
40 [return: BadReturn("The extension of the specified path (including the period).")]
41 private string GetExtension([BadParameter(description: "The path of a file or directory.")] string path)
42 {
43 return Path.GetExtension(path);
44 }
45
46 [BadMethod(description: "Returns the absolute path for the specified path string.")]
47 [return: BadReturn("The fully qualified location of path, such as \"C:\\MyFile.txt\" or \"/home/user/myFolder\".")]
48 private string GetFullPath([BadParameter(description: "The path of a file or directory.")] string path)
49 {
50 return m_FileSystem.GetFullPath(path);
51 }
52
53 [BadMethod(description: "Returns the Startup Directory.")]
54 [return: BadReturn("The Startup Directory")]
55 private string GetStartupPath()
56 {
58 }
59
60 [BadMethod(description: "Changes the extension of a path string.")]
61 [return: BadReturn("The modified path information.")]
62 private string ChangeExtension(
63 [BadParameter(description: "The path information to modify.")]
64 string path,
65 [BadParameter(description: "The new extension (with or without a leading period). Specify null to remove an existing extension from path")]
66 string extension)
67 {
68 return Path.ChangeExtension(path, extension);
69 }
70
71 [BadMethod(description: "Combines two or more strings into a path.")]
72 [return: BadReturn("The combined path.")]
73 private string Combine([BadParameter(description: "The Path Parts")] params string[] parts)
74 {
75 return Path.Combine(parts);
76 }
77}
Public interface for the filesystem abstraction of the BadScript Engine.
static IFileSystem Instance
File System implementation.
string GetExtension([BadParameter(description:"The path of a file or directory.")] string path)
Definition BadPathApi.cs:41
string GetFileNameWithoutExtension([BadParameter(description:"The Path to get the file name from.")] string path)
Definition BadPathApi.cs:27
readonly IFileSystem m_FileSystem
The FileSystem Instance.
Definition BadPathApi.cs:11
string ChangeExtension([BadParameter(description:"The path information to modify.")] string path, [BadParameter(description:"The new extension (with or without a leading period). Specify null to remove an existing extension from path")] string extension)
Definition BadPathApi.cs:62
string GetFullPath([BadParameter(description:"The path of a file or directory.")] string path)
Definition BadPathApi.cs:48
BadPathApi(IFileSystem fileSystem)
Definition BadPathApi.cs:13
string Combine([BadParameter(description:"The Path Parts")] params string[] parts)
Definition BadPathApi.cs:73
string? GetDirectoryName([BadParameter(description:"The path of a file or directory.")] string path)
Definition BadPathApi.cs:34
string GetFileName([BadParameter(description:"The Path to get the file name from.")] string path)
Definition BadPathApi.cs:20
Defines the interface for a file system.
Definition IFileSystem.cs:7
string GetStartupDirectory()
The Startup Directory of the Application.
string GetFullPath(string path)
Returns the full path of the given path.
Contains IO Implementation for the BadScript2 Runtime.
Contains IO Extensions and APIs for the BadScript2 Runtime.