11#if UNITY_EDITOR || ( MODIO_COMPILE_ALL && UNITY_EDITOR )
22
3+ using System ;
34using System . Collections . Generic ;
5+ using System . IO ;
46using System . Threading . Tasks ;
7+ using UnityEngine ;
58
69#pragma warning disable 1998 // These async functions don't use await!
710
@@ -12,18 +15,18 @@ internal class EditorDataService : IUserDataService, IPersistentDataService, ITe
1215 {
1316 /// <summary>Root directory for all data services.</summary>
1417 public readonly static string GlobalRootDirectory =
15- $@ "{ System . IO . Directory . GetCurrentDirectory ( ) } /mod.io";
18+ $@ "{ Application . persistentDataPath } /mod.io";
1619
1720#region Data
1821
1922 /// <summary>Root directory for the data service.</summary>
20- string rootDir = null ;
23+ string rootDir ;
2124
2225 /// <summary>Root directory for the data service.</summary>
2326 public string RootDirectory
2427 {
2528 get {
26- return this . rootDir ;
29+ return rootDir ;
2730 }
2831 }
2932
@@ -35,9 +38,8 @@ public string RootDirectory
3538 async Task < Result > IUserDataService . InitializeAsync ( string userProfileIdentifier ,
3639 long gameId , BuildSettings settings )
3740 {
38- // TODO(@jackson): Test dir creation
39- this . rootDir =
40- $ "{ EditorDataService . GlobalRootDirectory } /{ gameId . ToString ( "00000" ) } /users/{ userProfileIdentifier } ";
41+ rootDir =
42+ $ "{ GlobalRootDirectory } /{ gameId . ToString ( "00000" ) } /users/{ userProfileIdentifier } ";
4143
4244 Logger . Log ( LogLevel . Verbose , "Initialized EditorUserDataService: " + rootDir ) ;
4345
@@ -48,21 +50,19 @@ async Task<Result> IUserDataService.InitializeAsync(string userProfileIdentifier
4850 async Task < Result > IPersistentDataService . InitializeAsync ( long gameId ,
4951 BuildSettings settings )
5052 {
51- // TODO(@jackson): Test dir creation
52- this . rootDir =
53- $ "{ EditorDataService . GlobalRootDirectory } /{ gameId . ToString ( "00000" ) } /data";
53+ rootDir =
54+ $ "{ GlobalRootDirectory } /{ gameId . ToString ( "00000" ) } /data";
5455
55- Logger . Log ( LogLevel . Verbose , "Initialized EditorDataService as IPDS : " + rootDir ) ;
56+ Logger . Log ( LogLevel . Verbose , "Initialized EditorPersistentDataService : " + rootDir ) ;
5657
5758 return ResultBuilder . Success ;
5859 }
5960
6061 /// <summary>Init as ITempDataService.</summary>
6162 async Task < Result > ITempDataService . InitializeAsync ( long gameId , BuildSettings settings )
6263 {
63- // TODO(@jackson): Test dir creation
64- this . rootDir =
65- $ "{ EditorDataService . GlobalRootDirectory } /{ gameId . ToString ( "00000" ) } /temp";
64+ rootDir =
65+ $ "{ GlobalRootDirectory } /{ gameId . ToString ( "00000" ) } /temp";
6666
6767 Logger . Log ( LogLevel . Verbose , "Initialized EditorTempDataService: " + rootDir ) ;
6868
@@ -76,52 +76,68 @@ async Task<Result> ITempDataService.InitializeAsync(long gameId, BuildSettings s
7676 /// <summary>Opens a file stream for reading.</summary>
7777 public ModIOFileStream OpenReadStream ( string filePath , out Result result )
7878 {
79- DebugUtil . AssertPathValid ( filePath , this . rootDir ) ;
79+ // DebugUtil.AssertPathValid(filePath, rootDir);
8080 return SystemIOWrapper . OpenReadStream ( filePath , out result ) ;
8181 }
8282
8383 /// <summary>Opens a file stream for writing.</summary>
8484 public ModIOFileStream OpenWriteStream ( string filePath , out Result result )
8585 {
86- DebugUtil . AssertPathValid ( filePath , this . rootDir ) ;
86+ // DebugUtil.AssertPathValid(filePath, rootDir);
8787 return SystemIOWrapper . OpenWriteStream ( filePath , out result ) ;
8888 }
8989
9090 /// <summary>Reads an entire file asynchronously.</summary>
9191 public async Task < ResultAnd < byte [ ] > > ReadFileAsync ( string filePath )
9292 {
93- DebugUtil . AssertPathValid ( filePath , this . rootDir ) ;
93+ // DebugUtil.AssertPathValid(filePath, rootDir);
9494 return await SystemIOWrapper . ReadFileAsync ( filePath ) ;
9595 }
9696
9797 /// <summary>Writes an entire file asynchronously.</summary>
9898 public async Task < Result > WriteFileAsync ( string filePath , byte [ ] data )
9999 {
100- DebugUtil . AssertPathValid ( filePath , this . rootDir ) ;
100+ // DebugUtil.AssertPathValid(filePath, rootDir);
101101 return await SystemIOWrapper . WriteFileAsync ( filePath , data ) ;
102102 }
103103
104104 /// <summary>Deletes a file.</summary>
105105 public async Task < Result > DeleteFileAsync ( string filePath )
106106 {
107- throw new System . NotImplementedException ( ) ;
107+ throw new NotImplementedException ( ) ;
108108 }
109109
110110 /// <summary>Deletes a directory and its contents recursively.</summary>
111111 public Result DeleteDirectory ( string directoryPath )
112112 {
113- DebugUtil . AssertPathValid ( directoryPath , this . rootDir ) ;
113+ // DebugUtil.AssertPathValid(directoryPath, rootDir);
114114 return SystemIOWrapper . DeleteDirectory ( directoryPath ) ;
115115 }
116116
117+ public Result MoveDirectory ( string directoryPath , string newDirectoryPath )
118+ {
119+ return SystemIOWrapper . MoveDirectory ( directoryPath , newDirectoryPath ) ;
120+ }
121+
122+ public bool TryCreateParentDirectory ( string path )
123+ {
124+ return SystemIOWrapper . TryCreateParentDirectory ( path , out Result _ ) ;
125+ }
126+
127+ public bool IsThereEnoughDiskSpaceFor ( long bytes )
128+ {
129+ // Not implemented for this platform
130+ return true ;
131+ }
132+
117133#endregion // Operations
118134
119135#region Utility
120136
121137 /// <summary>Determines whether a file exists.</summary>
122138 public bool FileExists ( string filePath )
123139 {
124- DebugUtil . AssertPathValid ( filePath , this . rootDir ) ;
140+ // DebugUtil.AssertPathValid(filePath, rootDir);
125141 return SystemIOWrapper . FileExists ( filePath , out Result r ) ;
126142 }
127143
@@ -135,18 +151,18 @@ public ResultAnd<List<string>> ListAllFiles(string directoryPath)
135151 public async Task < ResultAnd < ( long fileSize , string fileHash ) > > GetFileSizeAndHash (
136152 string filePath )
137153 {
138- DebugUtil . AssertPathValid ( filePath , this . rootDir ) ;
154+ // DebugUtil.AssertPathValid(filePath, rootDir);
139155 return await SystemIOWrapper . GetFileSizeAndHash ( filePath ) ;
140156 }
141157
142158 /// <summary>Determines whether a directory exists.</summary>
143159 public bool DirectoryExists ( string directoryPath )
144160 {
145- DebugUtil . AssertPathValid ( directoryPath , this . rootDir ) ;
161+ // DebugUtil.AssertPathValid(directoryPath, rootDir);
146162 return SystemIOWrapper . DirectoryExists ( directoryPath ) ;
147163 }
148164
149- /// <summary>Determines whether a path can be handled by this data service.</summary>
165+ // // / <summary>Determines whether a path can be handled by this data service.</summary>
150166 // public bool CanHandlePath(string path)
151167 // {
152168 // // NOTE(@jackson): For EditorDataService, all services handle all paths
0 commit comments