mirror of
https://github.com/AssetRipper/NativeFileDialogs.NET.git
synced 2026-11-13 20:05:46 -10:00
Implement PickFolder and use more nullables
This commit is contained in:
1 file changed
+20
-4
@@ -12,7 +12,7 @@ public static class Nfd
|
||||
{
|
||||
private static readonly NfdManager manager = new NfdManager();
|
||||
|
||||
public static NfdStatus OpenDialog(out string outPath, IDictionary<string, string>? filters = null, string? defaultPath = null)
|
||||
public static NfdStatus OpenDialog(out string? outPath, IDictionary<string, string>? filters = null, string? defaultPath = null)
|
||||
{
|
||||
manager.PushDialog();
|
||||
NfdnfilteritemT[] filterItems = ToFilterItems(filters);
|
||||
@@ -22,14 +22,14 @@ public static class Nfd
|
||||
{
|
||||
sbyte* outPathPtr;
|
||||
status = nfd.NFD_OpenDialogN(&outPathPtr, filterItems, (uint)filterItems.Length, defaultPath).ToNfdStatus();
|
||||
outPath = status == NfdStatus.Cancelled ? "" : new string(outPathPtr);
|
||||
outPath = status == NfdStatus.Cancelled ? null : new string(outPathPtr);
|
||||
}
|
||||
|
||||
manager.PullDialog();
|
||||
return status;
|
||||
}
|
||||
|
||||
public static NfdStatus OpenDialogMultiple(out string[] outPaths, IDictionary<string, string>? filters = null, string? defaultPath = null)
|
||||
public static NfdStatus OpenDialogMultiple(out string[]? outPaths, IDictionary<string, string>? filters = null, string? defaultPath = null)
|
||||
{
|
||||
manager.PushDialog();
|
||||
NfdnfilteritemT[] filterItems = ToFilterItems(filters);
|
||||
@@ -57,7 +57,7 @@ public static class Nfd
|
||||
}
|
||||
else
|
||||
{
|
||||
outPaths = Array.Empty<string>();
|
||||
outPaths = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,22 @@ public static class Nfd
|
||||
return status;
|
||||
}
|
||||
|
||||
public static NfdStatus PickFolder(out string? outPath, string? defaultPath = null)
|
||||
{
|
||||
manager.PushDialog();
|
||||
NfdStatus status;
|
||||
|
||||
unsafe
|
||||
{
|
||||
sbyte* outPathPtr;
|
||||
status = nfd.NFD_PickFolderN(&outPathPtr, defaultPath).ToNfdStatus();
|
||||
outPath = status == NfdStatus.Cancelled ? null : new string(outPathPtr);
|
||||
}
|
||||
|
||||
manager.PullDialog();
|
||||
return status;
|
||||
}
|
||||
|
||||
internal static NfdnfilteritemT[] ToFilterItems(IDictionary<string, string>? filters)
|
||||
{
|
||||
if (filters == null)
|
||||
|
||||
Reference in new issue
Block a user