Skip to content

Commit 41c9fdd

Browse files
authored
storage: support Windows (#39)
1 parent ad2f726 commit 41c9fdd

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

Packages/MobileSupportStorage/Runtime/MobileSupport.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"includePlatforms": [
66
"Android",
77
"Editor",
8-
"iOS"
8+
"iOS",
9+
"WindowsStandalone64"
910
],
1011
"excludePlatforms": [],
1112
"allowUnsafeCode": false,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// --------------------------------------------------------------
2+
// Copyright 2026 CyberAgent, Inc.
3+
// --------------------------------------------------------------
4+
5+
#if UNITY_STANDALONE_WIN
6+
using System.Runtime.InteropServices;
7+
using UnityEngine;
8+
9+
namespace MobileSupport
10+
{
11+
public static class Storage
12+
{
13+
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
14+
[return: MarshalAs(UnmanagedType.Bool)]
15+
private static extern bool GetDiskFreeSpaceEx(
16+
string lpDirectoryName,
17+
out ulong lpFreeBytesAvailable,
18+
out ulong lpTotalNumberOfBytes,
19+
out ulong lpTotalNumberOfFreeBytes);
20+
21+
/// <summary>
22+
/// Get usable space of internal storage.
23+
/// </summary>
24+
/// <returns>Bytes of usable space. It will return -1 for internal error and in Unity editor.</returns>
25+
public static long GetInternalUsableSpace()
26+
{
27+
#if UNITY_EDITOR
28+
if (Application.isEditor) return -1;
29+
#endif
30+
31+
if (GetDiskFreeSpaceEx(Application.persistentDataPath,
32+
out var freeBytesAvailable, out _, out _))
33+
return (long)freeBytesAvailable;
34+
35+
return -1;
36+
}
37+
}
38+
}
39+
#endif

Packages/MobileSupportStorage/Runtime/Scripts/Storage.Windows.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)