Skip to content

Commit 7fbd999

Browse files
committed
Remove FreeBSD special case inside getAvailableDiskSpace
1 parent 78babae commit 7fbd999

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

std/file.d

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5151,32 +5151,16 @@ ulong getAvailableDiskSpace(scope const(char)[] path) @safe
51515151
}
51525152
else version (Posix)
51535153
{
5154-
import std.string : toStringz;
5154+
import core.sys.posix.sys.statvfs : statvfs, statvfs_t;
5155+
import std.internal.cstring : tempCString;
51555156

5156-
version (FreeBSD)
5157-
{
5158-
import core.sys.posix.sys.statvfs : statfs, statfs_t;
5159-
5160-
statfs_t stats;
5161-
auto err = () @trusted {
5162-
return statfs(path.toStringz(), &stats);
5163-
} ();
5164-
cenforce(err == 0, "Cannot get available disk space");
5165-
5166-
return stats.f_bavail * stats.f_bsize;
5167-
}
5168-
else
5169-
{
5170-
import core.sys.posix.sys.statvfs : statvfs, statvfs_t;
5171-
5172-
statvfs_t stats;
5173-
auto err = () @trusted {
5174-
return statvfs(path.toStringz(), &stats);
5175-
} ();
5176-
cenforce(err == 0, "Cannot get available disk space");
5157+
statvfs_t stats;
5158+
auto err = () @trusted {
5159+
return statvfs(path.tempCString(), &stats);
5160+
} ();
5161+
cenforce(err == 0, "Cannot get available disk space");
51775162

5178-
return stats.f_bavail * stats.f_frsize;
5179-
}
5163+
return stats.f_bavail * stats.f_frsize;
51805164
}
51815165
else static assert(0, "Unsupported platform");
51825166
}

0 commit comments

Comments
 (0)