예제 #1
0
        /// <summary>Function for deleting a user-specific file.</summary>
        public static void DeleteFile(string filePathRelative, WriteFileCallback callback)
        {
            Debug.Assert(UserDataStorage.isInitialized);
            Debug.Assert(!string.IsNullOrEmpty(filePathRelative));

            string filePath = IOUtilities.CombinePath(UserDataStorage.activeUserDirectory, filePathRelative);

            UserDataStorage.PLATFORM.DeleteFile(filePath, callback);
        }
예제 #2
0
        /// <summary>Clears all user data. (Standalone Application)</summary>
        public static void ClearAllData_Standalone(WriteFileCallback callback)
        {
            bool success = IOUtilities.DeleteDirectory(UserDataStorage.STANDALONE_USERS_FOLDER);

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #3
0
        /// <summary>Clears all user data. (Unity Editor)</summary>
        public static void ClearAllData_Editor(WriteFileCallback callback)
        {
            bool success = IOUtilities.DeleteDirectory(UserDataStorage.EDITOR_RESOURCES_FOLDER);

            UnityEditor.AssetDatabase.Refresh();

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #4
0
        /// <summary>Writes a file.</summary>
        public static void WriteFile(string path, byte[] data, WriteFileCallback onComplete)
        {
            #if DEBUG
            if (data.Length == 0)
            {
                Debug.Log("[mod.io] Writing 0-byte file to: " + path);
            }
            #endif // DEBUG

            DataStorage.PLATFORM_IO.WriteFile(path, data, onComplete);
        }
예제 #5
0
        /// <summary>Writes a user data file. (Steamworks.NET)</summary>
        public static void WriteFile_SteamworksNET(string filePath, byte[] data, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath));
            Debug.Assert(data != null);

            bool success = Steamworks.SteamRemoteStorage.FileWrite(filePath, data, data.Length);

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #6
0
        /// <summary>Deletes a user data file. (Standalone Application)</summary>
        public static void DeleteFile_Standalone(string filePath, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath));

            bool success = false;

            success = IOUtilities.DeleteFile(filePath);

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #7
0
        /// <summary>Writes a file.</summary>
        public void WriteFile(string relativePath, byte[] data, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(relativePath));
            Debug.Assert(data != null);

            string path    = IOUtilities.CombinePath(this.userDir, relativePath);
            bool   success = Steamworks.SteamRemoteStorage.FileWrite(path, data, data.Length);

            if (callback != null)
            {
                callback.Invoke(relativePath, success);
            }
        }
예제 #8
0
        /// <summary>Function for writing a user-specific file.</summary>
        public static void WriteFile(string relativePath, byte[] data, WriteFileCallback callback)
        {
            Debug.Assert(data != null);

            #if DEBUG
            if (data.Length == 0)
            {
                Debug.LogWarning("[mod.io] Writing 0-byte user file to: " + relativePath);
            }
            #endif // DEBUG

            UserDataStorage.PLATFORM_IO.WriteFile(relativePath, data, callback);
        }
예제 #9
0
        /// <summary>Writes a user data file. (Standalone Application)</summary>
        public static void WriteFile_Standalone(string filePath, byte[] data, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath));
            Debug.Assert(data != null);

            bool success = false;

            success = IOUtilities.WriteBinaryFile(filePath, data);

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #10
0
        /// <summary>Function for writing a user-specific file.</summary>
        public static void WriteFile(string filePathRelative, byte[] fileData, WriteFileCallback callback)
        {
            Debug.Assert(UserDataStorage.isInitialized);
            Debug.Assert(!string.IsNullOrEmpty(filePathRelative));
            Debug.Assert(fileData != null);

            #if DEBUG
            if (fileData.Length == 0)
            {
                Debug.LogWarning("[mod.io] Writing 0-byte user file to: " + filePathRelative);
            }
            #endif // DEBUG

            string filePath = IOUtilities.CombinePath(UserDataStorage.activeUserDirectory, filePathRelative);
            UserDataStorage.PLATFORM.WriteFile(filePath, fileData, callback);
        }
예제 #11
0
        /// <summary>Deletes a user data file. (Steamworks.NET)</summary>
        public static void DeleteFile_SteamworksNET(string filePath, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath));

            bool success = true;

            if (Steamworks.SteamRemoteStorage.FileExists(filePath))
            {
                success = Steamworks.SteamRemoteStorage.FileDelete(filePath);
            }

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #12
0
        /// <summary>Clears all user data. (Facepunch.Steamworks)</summary>
        public static void ClearAllData_Facepunch(WriteFileCallback callback)
        {
            var  steamFiles = Steamworks.SteamRemoteStorage.Files;
            bool success    = true;

            foreach (string filePath in steamFiles)
            {
                if (filePath.StartsWith(UserDataStorage.FACEPUNCH_USER_DIRECTORY))
                {
                    success = Steamworks.SteamRemoteStorage.FileDelete(filePath) && success;
                }
            }

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #13
0
        /// <summary>Writes a JSON file.</summary>
        public static void WriteJSONFile <T>(string path, T jsonObject, WriteFileCallback onComplete)
        {
            byte[] data = IOUtilities.GenerateUTF8JSONData <T>(jsonObject);

            if (data != null && data.Length > 0)
            {
                DataStorage.PLATFORM_IO.WriteFile(path, data, onComplete);
            }
            else
            {
                Debug.LogWarning("[mod.io] Failed create JSON representation of object before writing file."
                                 + "\nFile: " + path + "\n\n");

                if (onComplete != null)
                {
                    onComplete.Invoke(path, false);
                }
            }
        }
예제 #14
0
        /// <summary>Function used to read a user data file.</summary>
        public static void WriteJSONFile <T>(string relativePath, T jsonObject, WriteFileCallback callback)
        {
            byte[] data = IOUtilities.GenerateUTF8JSONData <T>(jsonObject);

            if (data != null)
            {
                UserDataStorage.WriteFile(relativePath, data, callback);
            }
            else
            {
                Debug.LogWarning("[mod.io] Failed create JSON representation of object before writing file."
                                 + "\nFile: " + relativePath + "\n\n");

                if (callback != null)
                {
                    callback.Invoke(relativePath, false);
                }
            }
        }
예제 #15
0
        /// <summary>Write a user file. (Unity Editor)</summary>
        public static void WriteFile_Editor(string filePath, byte[] data, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath));
            Debug.Assert(data != null);

            bool fileExisted = System.IO.File.Exists(filePath);
            bool success     = false;

            success = IOUtilities.WriteBinaryFile(filePath, data);

            if (success && !fileExisted)
            {
                UnityEditor.AssetDatabase.Refresh();
            }

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #16
0
        /// <summary>Delete a user file. (Unity Editor)</summary>
        public static void DeleteFile_Editor(string filePath, WriteFileCallback callback)
        {
            Debug.Assert(!string.IsNullOrEmpty(filePath));

            bool fileExisted = System.IO.File.Exists(filePath);
            bool success     = true;

            if (fileExisted)
            {
                success = IOUtilities.DeleteFile(filePath);

                if (success)
                {
                    UnityEditor.AssetDatabase.Refresh();
                }
            }

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #17
0
        /// <summary>Clears all user data. (Steamworks.NET)</summary>
        public static void ClearAllData_SteamworksNET(WriteFileCallback callback)
        {
            int  fileCount = Steamworks.SteamRemoteStorage.GetFileCount();
            bool success   = true;

            for (int i = 0; i < fileCount; ++i)
            {
                string filePath;
                int    fileSize;

                filePath = Steamworks.SteamRemoteStorage.GetFileNameAndSize(i, out fileSize);

                if (filePath.StartsWith(UserDataStorage.STEAMWORKSNET_USER_DIRECTORY))
                {
                    success = Steamworks.SteamRemoteStorage.FileDelete(filePath) && success;
                }
            }

            if (callback != null)
            {
                callback.Invoke(success);
            }
        }
예제 #18
0
        /// <summary>Function used to read a user data file.</summary>
        public static void TryWriteJSONFile <T>(string filePathRelative, T jsonObject, WriteFileCallback callback)
        {
            Debug.Assert(UserDataStorage.isInitialized);
            Debug.Assert(!string.IsNullOrEmpty(filePathRelative));

            byte[] fileData = null;
            if (UserDataStorage.TryGenerateJSONFile(jsonObject, out fileData))
            {
                UserDataStorage.WriteFile(filePathRelative, fileData, callback);
            }
            else if (callback != null)
            {
                callback.Invoke(false);
            }
        }
예제 #19
0
        /// <summary>Function for clearing all user data.</summary>
        public static void ClearAllData(WriteFileCallback callback)
        {
            Debug.Assert(UserDataStorage.isInitialized);

            UserDataStorage.PLATFORM.ClearAllData(callback);
        }