Esempio n. 1
0
        private static void PrepareToLoadCloudFile(string path)
        {
            if (!Options.Data.cloud || !Steam.IsInitialized())
            {
                return;
            }
            string localSavePath = DuckFile.GetLocalSavePath(path);

            if (localSavePath == null)
            {
                return;
            }
            byte[] buffer = Steam.FileRead("nq403216_" + localSavePath);
            if (buffer == null)
            {
                return;
            }
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            FileStream fileStream = File.Create(path);

            fileStream.Write(buffer, 0, buffer.Length);
            fileStream.Close();
        }
Esempio n. 2
0
        public static string[] GetDirectories(string path)
        {
            path = path.Replace('\\', '/');
            List <string> stringList = new List <string>();

            if (Options.Data.cloud && !MonoMain.disableCloud && Steam.IsInitialized())
            {
                string localSavePath = DuckFile.GetLocalSavePath(path);
                if (localSavePath != null)
                {
                    int count = Steam.FileGetCount();
                    for (int file = 0; file < count; ++file)
                    {
                        string name = Steam.FileGetName(file);
                        int    num  = name.IndexOf(localSavePath);
                        if (num != -1 && name.StartsWith("nq403216_"))
                        {
                            if (localSavePath == "")
                            {
                                num += 12;
                            }
                            string str1   = name.Substring(num + localSavePath.Length, name.Length - (num + localSavePath.Length));
                            int    length = str1.IndexOf('/');
                            switch (length)
                            {
                            case -1:
                            case 0:
                                continue;

                            default:
                                string str2 = path + str1.Substring(0, length);
                                if (!stringList.Contains(str2))
                                {
                                    stringList.Add(str2);
                                    continue;
                                }
                                continue;
                            }
                        }
                    }
                }
            }
            path = path.Trim('/');
            if (!MonoMain.cloudOnly && Directory.Exists(path))
            {
                foreach (string path1 in DuckFile.GetDirectoriesNoCloud(path))
                {
                    if (!Path.GetFileName(path1).Contains("._"))
                    {
                        string str = path1.Replace('\\', '/');
                        if (!stringList.Contains(str))
                        {
                            stringList.Add(str);
                        }
                    }
                }
            }
            return(stringList.ToArray());
        }
Esempio n. 3
0
 public static void InitializeCloud()
 {
     if (!Steam.IsInitialized())
     {
         return;
     }
     try
     {
         string localSavePath = DuckFile.GetLocalSavePath(DuckFile.optionsDirectory + "options.dat");
         if (localSavePath == null)
         {
             return;
         }
         if (!Steam.FileExists("nq403216_" + localSavePath))
         {
             return;
         }
         try
         {
             XDocument xdocument = XDocument.Load((Stream) new MemoryStream(Steam.FileRead("nq403216_" + localSavePath)));
             if (xdocument != null)
             {
                 Profile profile = new Profile("");
                 IEnumerable <XElement> source = xdocument.Elements((XName)"Data");
                 if (source != null)
                 {
                     foreach (XElement element in source.Elements <XElement>())
                     {
                         if (element.Name.LocalName == "Options")
                         {
                             OptionsData optionsData = new OptionsData();
                             optionsData.Deserialize(element);
                             if (optionsData.cloud)
                             {
                                 DuckFile.cloudOverload = true;
                             }
                             Options.Data.cloud = optionsData.cloud;
                             break;
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
         }
         DuckFile.needsCloudInit = false;
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 4
0
        private static void SaveCloudFile(string path)
        {
            if (MonoMain.cloudNoSave || !Steam.IsInitialized())
            {
                return;
            }
            string localSavePath = DuckFile.GetLocalSavePath(path);

            if (localSavePath == null)
            {
                return;
            }
            byte[] data = File.ReadAllBytes(path);
            Steam.FileWrite("nq403216_" + localSavePath, data, data.Length);
        }
Esempio n. 5
0
        public static string[] GetFiles(string path, string filter = "*.*")
        {
            List <string> stringList = new List <string>();

            if (!MonoMain.cloudOnly && Directory.Exists(path))
            {
                stringList = DuckFile.GetFilesNoCloud(path, filter, DuckFile._getFilesOption);
                for (int index = 0; index < stringList.Count; ++index)
                {
                    stringList[index] = stringList[index].Replace('\\', '/');
                }
            }
            if (Options.Data.cloud && !MonoMain.disableCloud && Steam.IsInitialized())
            {
                string localSavePath = DuckFile.GetLocalSavePath(path);
                if (localSavePath != null)
                {
                    int count = Steam.FileGetCount();
                    for (int file = 0; file < count; ++file)
                    {
                        string name = Steam.FileGetName(file);
                        int    num  = name.IndexOf(localSavePath);
                        if (num != -1 && name.StartsWith("nq403216_") && num == "nq403216_".Length)
                        {
                            string source = name.Substring(num + localSavePath.Length, name.Length - (num + localSavePath.Length));
                            if (source[0] == '\\' || source[0] == '/')
                            {
                                source = source.Substring(1, source.Length - 1);
                            }
                            if (!source.Contains <char>('/') && !source.Contains <char>('\\') || DuckFile._getFilesOption == SearchOption.AllDirectories)
                            {
                                string str = path;
                                if (!str.EndsWith("/"))
                                {
                                    str += "/";
                                }
                                if (!stringList.Contains(str + source))
                                {
                                    stringList.Add(path + source);
                                }
                            }
                        }
                    }
                }
            }
            return(stringList.ToArray());
        }
Esempio n. 6
0
        public static void Delete(string file)
        {
            if (File.Exists(file))
            {
                File.SetAttributes(file, FileAttributes.Normal);
                File.Delete(file);
            }
            if (MonoMain.cloudNoSave || !Steam.IsInitialized())
            {
                return;
            }
            string localSavePath = DuckFile.GetLocalSavePath(file);

            if (localSavePath == null)
            {
                return;
            }
            Steam.FileDelete(localSavePath);
        }