示例#1
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);
            }
        }
示例#2
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);
            }
        }
示例#3
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);
            }
        }
示例#4
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);
            }
        }
示例#5
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);
            }
        }
示例#6
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);
            }
        }
示例#7
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);
            }
        }
示例#8
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);
            }
        }
示例#9
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);
            }
        }
示例#10
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);
                }
            }
        }
示例#11
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);
                }
            }
        }
示例#12
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);
            }
        }
示例#13
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);
            }
        }
示例#14
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);
            }
        }