Skip to content

Commit

Permalink
Filesystem: Provide the string writeFile overload at the interface level
Browse files Browse the repository at this point in the history
The string overload is just a convenience function and there is little
chance that it wll ever need to be overloaded.
  • Loading branch information
Geod24 committed Jun 24, 2024
1 parent b4096ef commit da0cb43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 21 deletions.
7 changes: 6 additions & 1 deletion source/dub/internal/io/filesystem.d
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ public interface Filesystem
public abstract string readText (in NativePath path) const scope;

/// Write to this file
public abstract void writeFile (in NativePath path, const(char)[] data) scope;
public final void writeFile (in NativePath path, const(char)[] data) scope
{
import std.string : representation;

this.writeFile(path, data.representation);
}

/// Ditto
public abstract void writeFile (in NativePath path, const(ubyte)[] data) scope;
Expand Down
13 changes: 0 additions & 13 deletions source/dub/internal/io/mockfs.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public final class MockFS : Filesystem {
return this.cwd.writeFile(path, data);
}

/// Ditto
public override void writeFile (in NativePath path, const(char)[] data)
scope
{
return this.cwd.writeFile(path, data);
}

/// Reads a file, returns the content as `ubyte[]`
public override ubyte[] readFile (in NativePath path) const scope
{
Expand Down Expand Up @@ -405,12 +398,6 @@ public class FSEntry
return cast(string) content;
}

/// Write to this file
public void writeFile (in NativePath path, const(char)[] data) scope
{
this.writeFile(path, data.representation);
}

/// Ditto
public void writeFile (in NativePath path, const(ubyte)[] data) scope
{
Expand Down
7 changes: 0 additions & 7 deletions source/dub/internal/io/realfs.d
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ public final class RealFS : Filesystem {
return dub.internal.vibecompat.core.file.writeFile(path, data);
}

/// Ditto
protected override void writeFile (in NativePath path, const(char)[] data)
scope
{
return dub.internal.vibecompat.core.file.writeFile(path, data);
}

/// Reads a file, returns the content as `ubyte[]`
public override ubyte[] readFile (in NativePath path) const scope
{
Expand Down

0 comments on commit da0cb43

Please sign in to comment.