示例#1
0
 public static void DeleteFile(ES2Settings settings)
 {
     if (settings.filenameData.IsFile())
     {
         if (ES2FileUtility.Exists(settings.filenameData.filePath))
         {
             ES2FileUtility.Delete(settings.filenameData.filePath);
         }
     }
     else if (settings.filenameData.IsFolder())
     {
         if (ES2DirectoryUtility.Exists(settings.filenameData.filePath))
         {
             ES2DirectoryUtility.Delete(settings.filenameData.filePath, true);
         }
     }
 }
示例#2
0
 public static void MoveFile(ES2Settings settings, ES2Settings newSettings)
 {
     if (settings.filenameData.IsFile())
     {
         if (ES2FileUtility.Exists(settings.filenameData.filePath))
         {
             if (!ES2DirectoryUtility.Exists(newSettings.filenameData.directoryPath))
             {
                 ES2DirectoryUtility.CreateDirectory(newSettings.filenameData.directoryPath);
             }
             ES2FileUtility.Move(settings.filenameData.filePath, newSettings.filenameData.filePath);
         }
     }
     else if (settings.filenameData.IsFolder() && ES2DirectoryUtility.Exists(settings.filenameData.filePath))
     {
         if (ES2DirectoryUtility.Exists(settings.filenameData.filePath))
         {
             ES2DirectoryUtility.Move(settings.filenameData.directoryPath, newSettings.filenameData.directoryPath);
         }
     }
 }
示例#3
0
    public static bool Exists(ES2Settings settings)
    {
        // Resources
        if (settings.saveLocation == ES2Settings.SaveLocation.Resources)
        {
            if (settings.filenameData.extension != ".bytes")
            {
                Debug.LogError("Easy Save 2 Error: Can only check existence of files from Resources with the extension '.bytes'.");
            }

            TextAsset data = Resources.Load(settings.filenameData.resourcesPath) as TextAsset;

            if (settings.filenameData.HasTag())
            {
                return(CheckForTagInBytes(settings.filenameData.tag, data.bytes));
            }
            else if (data != null)
            {
                return(true);
            }
            return(false);
        }
        else if (settings.saveLocation == ES2Settings.SaveLocation.PlayerPrefs)
        {
            if (!settings.filenameData.HasTag())
            {
                return(PlayerPrefs.HasKey(settings.filenameData.playerPrefsPath));
            }

            if (!PlayerPrefs.HasKey(settings.filenameData.playerPrefsPath))
            {
                return(false);
            }

            using (ES2Reader reader = ES2Reader.Create(settings))
            {
                bool exists = reader.TagExists();
                return(exists);
            }
        }
        else if (settings.filenameData.IsURL())
        {
            return(false);
        }

        else if (settings.filenameData.HasTag())
        {
            if (!ES2FileUtility.Exists(settings.filenameData.filePath))
            {
                return(false);
            }

            using (ES2Reader reader = ES2Reader.Create(settings))
            {
                bool exists = reader.TagExists();
                return(exists);
            }
        }
        else
        {
            if (settings.filenameData.IsFolder())
            {
                return(ES2DirectoryUtility.Exists(settings.filenameData.directoryPath));
            }
            return(ES2FileUtility.Exists(settings.filenameData.filePath));
        }
    }
示例#4
0
 public override bool MayRequireOverwrite()
 {
     return(ES2FileUtility.Exists(settings.filenameData.filePath));
 }