Skip to content

Commit 450e86c

Browse files
committed
fuck off ViewLocator
1 parent a118922 commit 450e86c

File tree

15 files changed

+336
-254
lines changed

15 files changed

+336
-254
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
namespace WriterSharp.PluginApi.FileSystem
2+
{
3+
4+
/// <summary>
5+
/// Represents a file on disk.
6+
/// Data-only structure.
7+
/// </summary>
8+
public interface IFile
9+
{
10+
11+
/// <summary>
12+
/// An absolute path to the file.
13+
/// </summary>
14+
public string AbsoluteFilepath { get; }
15+
16+
/// <summary>
17+
/// The name of the file.
18+
/// </summary>
19+
public string Name { get; }
20+
21+
}
22+
23+
}
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
using System;
2+
3+
4+
namespace WriterSharp.PluginApi.FileSystem
5+
{
6+
7+
/// <summary>
8+
/// A type-safe, flexible, sharded file-system for WriterSharp plugins to use for
9+
/// maximum safety, instead of the defaults.
10+
/// </summary>
11+
public interface IFileSystem
12+
{
13+
14+
#region Reading
15+
16+
/// <summary>
17+
/// Reads all text from a file.
18+
/// </summary>
19+
/// <param name="filepath">The path to the file</param>
20+
/// <returns>The contents of the file</returns>
21+
public string ReadAllText(string filepath);
22+
23+
/// <summary>
24+
/// Reads all text from a file.
25+
/// </summary>
26+
/// <param name="file">The file</param>
27+
/// <returns>The contents of the file</returns>
28+
public string ReadAllText(IFile file);
29+
30+
/// <summary>
31+
/// Reads all text from a file, as a list of lines.
32+
/// </summary>
33+
/// <param name="filepath">The path to the file</param>
34+
/// <returns>The contents of the file</returns>
35+
public string[] ReadAllLines(string filepath);
36+
37+
/// <summary>
38+
/// Reads all text from a file, as a list of lines.
39+
/// </summary>
40+
/// <param name="file">The file</param>
41+
/// <returns>The contents of the file</returns>
42+
public string[] ReadAllLines(IFile file);
43+
44+
/// <summary>
45+
/// Reads the very first line of a file.
46+
/// </summary>
47+
/// <param name="filepath">The path to the file</param>
48+
/// <returns>The first line of the file</returns>
49+
public string ReadLine(string filepath);
50+
51+
/// <summary>
52+
/// Reads the very first line of a file.
53+
/// </summary>
54+
/// <param name="file">The file</param>
55+
/// <returns>The first line of the file</returns>
56+
public string ReadLine(IFile file);
57+
58+
/// <summary>
59+
/// Reads a specific amount of characters from a file buffer.
60+
/// </summary>
61+
/// <param name="filepath">The path to the file</param>
62+
/// <param name="amount">The amount of characters to read</param>
63+
/// <param name="offset">The index from which to start reading the characters</param>
64+
/// <returns>A span of characters</returns>
65+
public Span<char> ReadCharacters(string filepath, ulong amount, long offset = 0);
66+
67+
/// <summary>
68+
/// Reads a specific amount of characters from a file buffer.
69+
/// </summary>
70+
/// <param name="file">The file</param>
71+
/// <param name="amount">The amount of characters to read</param>
72+
/// <param name="offset">The index from which to start reading the characters</param>
73+
/// <returns>A span of characters</returns>
74+
public Span<char> ReadCharacters(IFile file, ulong amount, long offset = 0);
75+
76+
#endregion
77+
78+
#region Writing
79+
80+
/// <summary>
81+
/// Writes text to a file, creating it if necessary. If the file exists,
82+
/// it will be overwritten.
83+
/// </summary>
84+
/// <param name="filepath">The path to the file</param>
85+
/// <param name="data">The text to write</param>
86+
public void WriteAllText(string filepath, string data);
87+
88+
/// <summary>
89+
/// Writes text to a file, creating it if necessary. If the file exists,
90+
/// it will be overwritten.
91+
/// </summary>
92+
/// <param name="file">The file</param>
93+
/// <param name="data">The text to write</param>
94+
public void WriteAllText(IFile file, string data);
95+
96+
/// <summary>
97+
/// Writes lines of text to a file, creating it if necessary.
98+
/// If the file exists, it will be overwritten.
99+
/// </summary>
100+
/// <param name="filepath">The path to the file</param>
101+
/// <param name="data">The lines of text to write</param>
102+
public void WriteAllLines(string filepath, string[] data);
103+
104+
/// <summary>
105+
/// Writes lines of text to a file, creating it if necessary.
106+
/// If the file exists, it will be overwritten.
107+
/// </summary>
108+
/// <param name="file">The file</param>
109+
/// <param name="data">The lines of text to write</param>
110+
public void WriteAllLines(IFile file, string[] data);
111+
112+
#endregion
113+
114+
#region Appending
115+
116+
/// <summary>
117+
/// Appends all the text to the end of a file.
118+
/// </summary>
119+
/// <param name="filepath">The path to the file</param>
120+
/// <param name="data">The text to append</param>
121+
public void AppendAllText(string filepath, string data);
122+
123+
/// <summary>
124+
/// Appends all the text to the end of a file.
125+
/// </summary>
126+
/// <param name="file">The file</param>
127+
/// <param name="data">The text to append</param>
128+
public void AppendAllText(IFile file, string data);
129+
130+
/// <summary>
131+
/// Appends all the specified lines of text to the end of a file.
132+
/// </summary>
133+
/// <param name="filepath">The path to the file</param>
134+
/// <param name="data">The lines to append</param>
135+
public void AppendAllLines(string filepath, string[] data);
136+
137+
/// <summary>
138+
/// Appends all the specified lines of text to the end of a file.
139+
/// </summary>
140+
/// <param name="file">The file</param>
141+
/// <param name="data">The lines to append</param>
142+
public void AppendAllLines(IFile file, string[] data);
143+
144+
#endregion
145+
146+
#region Sharding Toolkit
147+
148+
/// <summary>
149+
/// Checks if a file is in use by another plugin.
150+
/// A result of <c>false</c> does not mean the file is strictly
151+
/// not in use - it only means no other plugin is using it.
152+
/// </summary>
153+
/// <param name="filepath">The path to the file</param>
154+
/// <returns><c>true</c> if in use by another plugin</returns>
155+
public bool InUse(string filepath);
156+
157+
/// <summary>
158+
/// Checks if a file is in use by another plugin.
159+
/// A result of <c>false</c> does not mean the file is strictly
160+
/// not in use - it only means no other plugin is using it.
161+
/// </summary>
162+
/// <param name="filepath">The file</param>
163+
/// <returns><c>true</c> if in use by another plugin</returns>
164+
public bool InUse(IFile filepath);
165+
166+
#endregion
167+
168+
#region Locking
169+
170+
// todo: this shit
171+
172+
#endregion
173+
174+
}
175+
176+
}
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
namespace WriterSharp.PluginApi
22
{
33

4-
public interface IPluginContextV1
4+
/// <summary>
5+
/// The plugin context.
6+
/// </summary>
7+
public interface IPluginContext
58
{
69

10+
/// <summary>
11+
/// The sharded, recommended way for plugins to access
12+
/// files from disk.
13+
/// </summary>
14+
IFileSystem FileSystem { get; }
15+
716
/// <summary>
817
/// Manages languages loaded into WriterSharp.
918
/// </summary>
@@ -25,6 +34,11 @@ public interface IPluginContextV1
2534
/// </summary>
2635
IGestureManager Gestures { get; }
2736

37+
/// <summary>
38+
/// Manages commands that the user can call.
39+
/// </summary>
40+
ICommandManager Commands { get; }
41+
2842
/// <summary>
2943
/// Manages plugin's settings via WriterSharp (for security).
3044
/// </summary>

WriterSharp.PluginApi/Ini/IniParser.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

WriterSharp.Tests/WriterSharp.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
<ItemGroup>
3838
<ProjectReference Include="..\WriterSharp.Core\WriterSharp.Core.csproj" />
39-
<ProjectReference Include="..\WriterSharp\WriterSharp.csproj" />
4039
</ItemGroup>
4140

4241
<ItemGroup>

0 commit comments

Comments
 (0)