Ejemplo n.º 1
0
        public static string InitLogDir(string?alias = null)
        {
            var logDirPath = Path.Combine(AppContext.BaseDirectory, "Logs");

            IOPath.DirCreateByNotExists(logDirPath);
#if StartupTrace
            StartupTrace.Restart("InitLogDir.IO");
#endif
            var logDirPath_ = logDirPath + Path.DirectorySeparatorChar;

            InternalLogger.LogFile  = logDirPath_ + "internal-nlog" + alias + ".txt";
            InternalLogger.LogLevel = NLogLevel.Error;
            var objConfig = new LoggingConfiguration();
            var logfile   = new FileTarget("logfile")
            {
                FileName = logDirPath_ + "nlog-all-${shortdate}" + alias + ".log",
                Layout   = "${longdate}|${level}|${logger}|${message} |${all-event-properties} ${exception:format=tostring}",
            };
            objConfig.AddTarget(logfile);
            objConfig.AddRule(NLogLevel.Error, NLogLevel.Fatal, logfile, "Microsoft.*");
            objConfig.AddRule(NLogLevel.Error, NLogLevel.Fatal, logfile, "System.Net.Http.*");
            objConfig.AddRule(AppHelper.DefaultNLoggerMinLevel, NLogLevel.Fatal, logfile, "*");
#if StartupTrace
            StartupTrace.Restart("InitLogDir.CreateLoggingConfiguration");
#endif
            LogManager.Configuration = objConfig;

            return(logDirPath);
        }
Ejemplo n.º 2
0
 private void GetChildModel(TreeModel topModel)
 {
     if (File.Exists(topModel.AbsolutePath))
     {
         //topModel.ContextMenu = contextMenu;
         return;
     }
     else
     {
         //获取文件和文件夹
         string[] paths = Directory.GetFileSystemEntries(topModel.AbsolutePath, "*", SearchOption.TopDirectoryOnly);
         if (paths != null && paths.Length > 0)
         {
             for (int i = 0; i < paths.Length; i++)
             {
                 TreeModel childModel = new TreeModel();
                 childModel.AbsolutePath = paths[i];
                 childModel.DisplayName  = IOPath.GetFileName(childModel.AbsolutePath);
                 childModel.Parent       = topModel;
                 topModel.Children.Add(childModel);
                 GetChildModel(childModel);
             }
         }
     }
 }
Ejemplo n.º 3
0
        //加载录制歌单
        public void loadmyrecord(object sender, RoutedEventArgs e)
        {
            string folderPath = ConfigurationManager.AppSettings["myrecord"];

            folderPath = IOPath.GetFullPath(folderPath);

            string[] mp3Files = EntityService.GetMusicFiles(folderPath);
            if (mp3Files != null)
            {
                playList.Clear();
                mp3Files.ToList().ForEach(x => playList.Add(new Song()
                {
                    Location = x
                }));
                //获取歌词和歌曲数
                int i = 0;
                foreach (Song s in playList)
                {
                    singer_get(s);
                    s.LstLynic = GetLynicBySong(s);
                    i++;
                }
                this.num.Text = i.ToString();
            }
            this.songSheet.Text = "我录制的音乐";
            s2 = this.songSheet.Text;

            this.text01.Text = texts01[3].T1; //设置歌单标签
            this.text02.Text = texts01[3].T2; //设置歌单简介
        }
Ejemplo n.º 4
0
        public StatsSyncher(Session par1Session, StatFileWriter par2StatFileWriter, string par3File)
        {
            IsBusy         = false;
            Field_27437_b  = null;
            Field_27436_c  = null;
            Field_27427_l  = 0;
            Field_27426_m  = 0;
            UnsentDataFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append("_unsent.dat").ToString());
            DataFile       = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append(".dat").ToString());
            UnsentOldFile  = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append("_unsent.old").ToString());
            OldFile        = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append(".old").ToString());
            UnsentTempFile = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append("_unsent.tmp").ToString());
            TempFile       = IOPath.Combine(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username.ToLower()).Append(".tmp").ToString());

            if (!par1Session.Username.ToLower().Equals(par1Session.Username))
            {
                Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append("_unsent.dat").ToString(), UnsentDataFile);
                Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append(".dat").ToString(), DataFile);
                Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append("_unsent.old").ToString(), UnsentOldFile);
                Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append(".old").ToString(), OldFile);
                Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append("_unsent.tmp").ToString(), UnsentTempFile);
                Func_28214_a(par3File, (new StringBuilder()).Append("stats_").Append(par1Session.Username).Append(".tmp").ToString(), TempFile);
            }

            StatFileWriter = par2StatFileWriter;
            TheSession     = par1Session;

            if (File.Exists(UnsentDataFile))
            {
                par2StatFileWriter.Func_27179_a(Func_27415_a(UnsentDataFile, UnsentTempFile, UnsentOldFile));
            }

            BeginReceiveStats();
        }
        public TexturePackList(Minecraft par1Minecraft, string par2File)
        {
            availableTexturePacks = new List <TexturePackBase>();
            DefaultTexturePack    = new TexturePackDefault(par1Minecraft);
            Field_6538_d          = new Dictionary <string, TexturePackBase>();
            Mc             = par1Minecraft;
            TexturePackDir = IOPath.Combine(par2File, "Texturepacks");

            if (Directory.Exists(TexturePackDir))
            {
                if (File.Exists(TexturePackDir))
                {
                    File.Delete(TexturePackDir);
                    Directory.CreateDirectory(TexturePackDir);
                }
            }
            else
            {
                Directory.CreateDirectory(TexturePackDir);
            }

            CurrentTexturePack = par1Minecraft.GameSettings.Skin;
            UpdateAvaliableTexturePacks();
            SelectedTexturePack.Func_6482_a();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// @args: Takes two arguments - first the name of the directory containing the world and second the new name for
        /// that world. @desc: Renames the world by storing the new name in level.dat. It does *not* rename the directory
        /// containing the world data.
        /// </summary>
        public virtual void RenameWorld(string par1Str, string par2Str)
        {
            string file = IOPath.Combine(SavesDirectory, par1Str);

            if (!File.Exists(file))
            {
                return;
            }

            string file1 = IOPath.Combine(file, "level.dat");

            if (File.Exists(file1))
            {
                try
                {
                    NBTTagCompound nbttagcompound  = CompressedStreamTools.ReadCompressed(new FileStream(file1, FileMode.Open));
                    NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Data");
                    nbttagcompound1.SetString("LevelName", par2Str);
                    CompressedStreamTools.WriteCompressed(nbttagcompound, new FileStream(file1, FileMode.Create));
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                    Console.Write(exception.StackTrace);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 根据文件清单生成压缩包
        /// </summary>
        /// <param name="dev"></param>
        /// <param name="item"></param>
        /// <param name="type"></param>
        public static void GenerateCompressedPackage(bool dev, PublishDirInfo item, AppDownloadType type)
        {
            var fileEx = GetFileExByCompressedType(type);

            var packPath = GetPackPath(dev, item, fileEx);

            Console.WriteLine($"正在生成压缩包:{packPath}");
            IOPath.FileIfExistsItDelete(packPath);

            GetCreatePackByCompressedType(type)(packPath, item.Files);

            using var fileStream = File.OpenRead(packPath);
            var sha256 = Hashs.String.SHA256(fileStream);

            var fileInfoM = new PublishFileInfo
            {
                SHA256 = sha256,
                Length = fileStream.Length,
                Path   = packPath,
            };

            if (item.BuildDownloads.ContainsKey(type))
            {
                item.BuildDownloads[type] = fileInfoM;
            }
            else
            {
                item.BuildDownloads.Add(type, fileInfoM);
            }
        }
Ejemplo n.º 8
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.rollingText.Text = "音乐播放器处于暂停状态";
            //this.rollingText.label1.ForeColor = System.Drawing.Color.Blue;

            this.listBox.DataContext  = playList;
            playerhandle              = player.GetPlayerHandle();
            playerhandle.MediaEnded  += playerhandle_MediaEnded;
            playerhandle.MediaFailed += playerhandle_MediaFailed;
            playerhandle.MediaOpened += playerhandle_MediaOpened;
            player.playEvent         += player_playEvent;
            player.playEvent_thread  += player_playEvent_thread;

            this.slider.DataContext = player;


            //读取配置
            string folderPath = ConfigurationManager.AppSettings["folderPath"];

            folderPath = IOPath.GetFullPath(folderPath);
            if (!Directory.Exists(folderPath))
            {
                return;
            }
            GetMP3Files(folderPath).ToList().ForEach(x => playList.Add(new Song()
            {
                Location = x
            }));
            //获取歌词
            foreach (Song s in playList)
            {
                s.LstLynic = GetLynicBySong(s);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// par: filename for the level.dat_mcr backup
        /// </summary>
        private void createFile(string par1Str)
        {
            string file = IOPath.Combine(SavesDirectory, par1Str);

            //PROBLEMS AHHHHHH
            if (!File.Exists(file))
            {
                Console.WriteLine("Warning: Unable to create level.dat_mcr backup");
                return;
            }

            string file1 = IOPath.Combine(file, "level.dat");

            if (!File.Exists(file1))
            {
                Console.WriteLine("Warning: Unable to create level.dat_mcr backup");
                return;
            }

            string file2 = IOPath.Combine(file, "level.dat_mcr");

            try
            {
                File.Move(file1, file2);
            }
            catch (Exception e)
            {
                Utilities.LogException(e);

                Console.WriteLine("Warning: Unable to create level.dat_mcr backup");
            }
        }
Ejemplo n.º 10
0
 public static void OnAssemblyInitialize(TestContext context)
 {
     Path = IOPath.GetFullPath(IOPath.Combine(context.TestDir, string.Format("..\\TestLog_{0:yyyy-MM-dd HH_mm_ss}.csv", DateTime.Now)));
     File.WriteAllLines(Path, new[] {
         "date-time,duration,result,feature-title,scenario-title"
     });
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Checks the session lock to prevent save collisions
        /// </summary>
        public virtual void CheckSessionLock()
        {
            try
            {
                string       file            = IOPath.Combine(SaveDirectory, "session.lock");
                BinaryReader datainputstream = new BinaryReader(new FileStream(file, FileMode.Open));

                try
                {
                    if (datainputstream.ReadInt64() != InitializationTime)
                    {
                        throw new MinecraftException("The save is being accessed from another location, aborting");
                    }
                }
                finally
                {
                    datainputstream.Close();
                }
            }
            catch (IOException ioexception)
            {
                Console.WriteLine(ioexception.ToString());
                Console.WriteLine();

                throw new MinecraftException("Failed to check session lock, aborting");
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Loads an unmanaged library from filesystem
        /// </summary>
        /// <param name="fullFileName">full qualified name of the library file</param>
        /// <param name="fileVersion">optional file version to check major and minor</param>
        /// <returns>handle to library</returns>
        /// <exception cref="FileNotFoundException">File is missing</exception>
        /// <exception cref="Win32Exception">Unable to load library</exception>
        /// <exception cref="FileLoadException">A version mismatch occurs</exception>
        /// <exception cref="ArgumentNullException">fullFileName is null or empty</exception>
        /// <exception cref="NetOfficeIOException">I/O related error</exception>
        public static CdeclHandle LoadLibrary(string fullFileName, Version fileVersion = null)
        {
            if (String.IsNullOrWhiteSpace(fullFileName))
            {
                throw new ArgumentNullException("fullFileName");
            }
            if (!File.Exists(fullFileName))
            {
                throw new FileNotFoundException("File is missing.", fullFileName);
            }

            string folder   = IOPath.GetDirectoryName(fullFileName);
            string fileName = IOPath.GetFileName(fullFileName);

            if (null != fileVersion)
            {
                FileVersionInfo version = FileVersionInfo.GetVersionInfo(fullFileName);
                if (version.FileMajorPart != fileVersion.Major ||
                    version.FileMinorPart != fileVersion.Minor)
                {
                    throw new FileLoadException(
                              String.Format("Unable to load library <{0}> because a version mismatch occurs.", fileName));
                }
            }

            IntPtr ptr = Interop.LoadLibrary(fullFileName);

            if (ptr == IntPtr.Zero)
            {
                throw new Win32Exception(String.Format("Unable to load library <{0}>.", fileName));
            }

            return(new CdeclHandle(ptr, folder, fileName));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 初始化文件系统
        /// </summary>
        public static void InitFileSystem()
        {
            //var appDataRootPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            //if (string.IsNullOrWhiteSpace(appDataRootPath))
            //{
            //    // 需要测试 macOS 和 linux 上 Environment.SpecialFolder.ApplicationData 返回的目录值
            //    // 之前在 android 上测试过 Environment.GetFolderPath 有些枚举值返回的是空字符串 比如StartMenu
            //    throw new ArgumentNullException(nameof(appDataRootPath));
            //}
            //appDataRootPath = Path.Combine(appDataRootPath, BuildConfig.APPLICATION_ID);

            var appDataRootPath =
#if NET35
                WinFormsApplication.StartupPath;
#else
                AppContext.BaseDirectory;
#endif

            var appDataPath = Path.Combine(appDataRootPath, AppDataDirName);
            var cachePath   = Path.Combine(appDataRootPath, CacheDirName);
            IOPath.DirCreateByNotExists(appDataPath);
            IOPath.DirCreateByNotExists(cachePath);
            IOPath.InitFileSystem(GetAppDataDirectory, GetCacheDirectory);
            string GetAppDataDirectory() => appDataPath;
            string GetCacheDirectory() => cachePath;
        }
Ejemplo n.º 14
0
        public static new Tuple <DirectoryEntry, ImmutableList <ProjectEntry> > Create(DirectoryInfo dir, string relativePath)
        {
            var dirsAndProjects = from d in dir.EnumerateDirectories()
                                  where !d.IsHidden() &&
                                  !d.Name.Equals("bin", StringComparison.OrdinalIgnoreCase) &&
                                  !d.Name.Equals("obj", StringComparison.OrdinalIgnoreCase)
                                  orderby d.Name
                                  select Create(d, IOPath.Combine(relativePath, d.Name));

            var dirs = ImmutableList.CreateBuilder <DirectoryEntry>();

            foreach (var dap in dirsAndProjects)
            {
                // Discard sub-projects
                dirs.Add(dap.Item1);
            }

            var files = from f in dir.EnumerateFiles()
                        where !f.IsHidden()
                        orderby f.Name
                        select(Entry) FileEntry.Create(f, IOPath.Combine(relativePath, f.Name));

            var project = new ProjectEntry(relativePath, false, dir, dirs.ToImmutable(), files.ToImmutableList(),
                                           new ReferencesEntry(false, relativePath + ":references", ImmutableList.Create <ReferenceEntry>()), -1);

            return(new Tuple <DirectoryEntry, ImmutableList <ProjectEntry> >(
                       project,
                       ImmutableList.Create(project)));
        }
Ejemplo n.º 15
0
        static Library()
        {
            Version  = string.Empty;
            Id       = string.Empty;
            Platform = string.Empty;

            ResolveDotNetAssemblies = true;

            var text = ImplementationResources.Configuration;

            var separators = new[] { '\r', '\n' };
            var lines      = text.Split(separators, StringSplitOptions.RemoveEmptyEntries);

            Version = Find("Version", lines);

            using (var stream = new FileStream(typeof(Library).Assembly.Location, FileMode.Open, FileAccess.Read))
            {
                using (var sha1 = SHA1.Create())
                {
                    var hash = sha1.ComputeHash(stream);
                    var id   = BitConverter.ToString(hash);
                    Id = id.Replace("-", string.Empty);
                }
            }

            Platform = Environment.Is64BitProcess ? "x64" : "x86";

            var appData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

            LibPath = IOPath.Combine(appData, FdkLibsName, Library.Id, Library.Platform);
        }
Ejemplo n.º 16
0
        public void IOPathImplicitBackTest()
        {
            IOPath ioPath = new IOPath("test");
            string temp   = "test";
            IOPath target = temp;

            Assert.AreEqual(target, ioPath);
        }
Ejemplo n.º 17
0
        public void IOPathImplicitTest()
        {
            string path   = "test";
            IOPath target = new IOPath("test");
            string temp   = target;

            Assert.AreEqual(temp, path);
        }
Ejemplo n.º 18
0
        static SQLiteAsyncConnection GetConnection()
        {
            var dbPath = DataBaseDirectory;

            IOPath.DirCreateByNotExists(dbPath);
            dbPath = Path.Combine(dbPath, "application.dbf");
            return(new SQLiteAsyncConnection(dbPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create | SQLiteOpenFlags.SharedCache));
        }
Ejemplo n.º 19
0
        private void Func_28214_a(string par1File, string par2Str, string par3File)
        {
            string file = IOPath.Combine(par1File, par2Str);

            if (File.Exists(file) && !Directory.Exists(file) && !File.Exists(par3File))
            {
                File.Move(file, par3File);
            }
        }
Ejemplo n.º 20
0
        public void IsExistedDirectoryTest1()
        {
            string path     = "C:\\temp";
            IOPath target   = new IOPath(path);
            bool   expected = true;
            bool   actual;

            actual = target.IsExistedDirectory();
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 21
0
        public void IsExistedDirectoryTest2()
        {
            string path     = "C:\\temp\\scardsvr.exe";
            IOPath target   = new IOPath(path);
            bool   expected = false;
            bool   actual;

            actual = target.IsExistedDirectory();
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 22
0
        public void IsExistedDirectoryTest4()
        {
            string path     = null;
            IOPath target   = new IOPath(path);
            bool   expected = false;
            bool   actual;

            actual = target.IsExistedDirectory();
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 23
0
        public void LastDirectoryTestL()
        {
            string path     = "C:/temp/test.exe";     // TODO: 初始化为适当的值
            IOPath target   = new IOPath(path);       // TODO: 初始化为适当的值
            string expected = "C:/temp/";             // TODO: 初始化为适当的值
            string actual;

            actual = target.LastDirectory();
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 24
0
        public void ToStringTest()
        {
            string path     = "test";           // TODO: 初始化为适当的值
            IOPath target   = new IOPath(path); // TODO: 初始化为适当的值
            string expected = "test";           // TODO: 初始化为适当的值
            string actual;

            actual = target.ToString();
            Assert.AreEqual(expected, actual);
        }
        protected override void OverwriteUpgrade(string value, bool isIncrement)
        {
            if (isIncrement) // 增量更新
            {
                OverwriteUpgradePrivate(value);
            }
            else // 全量更新
            {
                var dirPath = Path.Combine(AppContext.BaseDirectory, Path.GetFileNameWithoutExtension(value));

                if (Directory.Exists(dirPath))
                {
                    Directory.Delete(dirPath, true);
                }

                if (TarGZipHelper.Unpack(value, dirPath, progress: new Progress <float>(OnReportDecompressing), maxProgress: MaxProgressValue))
                {
                    OnReport(MaxProgressValue);
                    IOPath.FileTryDelete(value);
                    OverwriteUpgradePrivate(dirPath);
                }
                else
                {
                    toast.Show(SR.UpdateUnpackFail);
                    OnReport(MaxProgressValue);
                }
            }

            void OverwriteUpgradePrivate(string dirPath)
            {
                OnExit();

                var updateCommandPath = Path.Combine(IOPath.CacheDirectory, "update.cmd");

                IOPath.FileIfExistsItDelete(updateCommandPath);

                var updateCommand = string.Format(
                    SR.ProgramUpdateCmd_,
                    AppHelper.ProgramName,
                    dirPath.TrimEnd(Path.DirectorySeparatorChar),
                    AppContext.BaseDirectory,
                    AppHelper.ProgramPath);

                updateCommand = "chcp" + Environment.NewLine + "chcp 65001" + Environment.NewLine + updateCommand;

                File.WriteAllText(updateCommandPath, updateCommand, Encoding.UTF8);

                using var p                 = new Process();
                p.StartInfo.FileName        = updateCommandPath;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.CreateNoWindow  = !ThisAssembly.Debuggable; // 不显示程序窗口
                p.StartInfo.Verb            = "runas";                  // 管理员权限运行
                p.Start();                                              // 启动程序
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Converts the specified map to the new map format. Args: worldName, loadingScreen
        /// </summary>
        public override bool ConvertMapFormat(string par1Str, IProgressUpdate par2IProgressUpdate)
        {
            par2IProgressUpdate.SetLoadingProgress(0);
            List <string> arraylist  = new List <string>();
            List <string> arraylist1 = new List <string>();
            List <string> arraylist2 = new List <string>();
            string        file       = IOPath.Combine(SavesDirectory, par1Str);
            string        file1      = IOPath.Combine(file, "DIM-1");
            string        file2      = IOPath.Combine(file, "DIM1");

            Console.WriteLine("Scanning folders...");
            Func_48432_a(file, arraylist);

            if (File.Exists(file1))
            {
                Func_48432_a(file1, arraylist1);
            }

            if (File.Exists(file2))
            {
                Func_48432_a(file2, arraylist2);
            }

            int i = arraylist.Count + arraylist1.Count + arraylist2.Count;

            Console.WriteLine((new StringBuilder()).Append("Total conversion count is ").Append(i).ToString());
            WorldInfo worldinfo = GetWorldInfo(par1Str);
            object    obj       = null;

            if (worldinfo.GetTerrainType() == WorldType.FLAT)
            {
                obj = new WorldChunkManagerHell(BiomeGenBase.Plains, 0.5F, 0.5F);
            }
            else
            {
                obj = new WorldChunkManager(worldinfo.GetSeed(), worldinfo.GetTerrainType());
            }

            Func_48428_a(IOPath.Combine(file, "region"), arraylist, ((WorldChunkManager)(obj)), 0, i, par2IProgressUpdate);
            Func_48428_a(IOPath.Combine(file1, "region"), arraylist1, new WorldChunkManagerHell(BiomeGenBase.Hell, 1.0F, 0.0F), arraylist.Count, i, par2IProgressUpdate);
            Func_48428_a(IOPath.Combine(file2, "region"), arraylist2, new WorldChunkManagerHell(BiomeGenBase.Sky, 0.5F, 0.0F), arraylist.Count + arraylist1.Count, i, par2IProgressUpdate);
            worldinfo.SetSaveVersion(19133);

            if (worldinfo.GetTerrainType() == WorldType.DEFAULT_1_1)
            {
                worldinfo.SetTerrainType(WorldType.DEFAULT);
            }

            createFile(par1Str);
            ISaveHandler isavehandler = GetSaveLoader(par1Str, false);

            isavehandler.SaveWorldInfo(worldinfo);
            return(true);
        }
Ejemplo n.º 27
0
        public static void InitFileSystemByBaseDirectory()
        {
            var appDataPath = BaseDirectory.AppDataDirectory;
            var cachePath   = BaseDirectory.CacheDirectory;

            IOPath.DirCreateByNotExists(appDataPath);
            IOPath.DirCreateByNotExists(cachePath);
            InitFileSystem(GetAppDataDirectory, GetCacheDirectory);
            string GetAppDataDirectory() => appDataPath;
            string GetCacheDirectory() => cachePath;
        }
Ejemplo n.º 28
0
        private void Func_48432_a(string par1File, List <string> par2ArrayList)
        {
            string[] afile = Directory.GetFiles(IOPath.Combine(par1File, "region"), AnvilSaveConverterFileFilter.SearchString);

            if (afile != null)
            {
                for (int i = 0; i < afile.Length; i++)
                {
                    par2ArrayList.Add(afile[i]);
                }
            }
        }
        /// <inheritdoc cref="FileSystem2.InitFileSystem"/>
        public static void InitFileSystem()
        {
            // https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/FileSystem/FileSystem.ios.tvos.watchos.macos.cs
            var appDataPath = Path.Combine(GetDirectory(NSSearchPathDirectory.LibraryDirectory), Constants.HARDCODED_APP_NAME);
            var cachePath   = Path.Combine(GetDirectory(NSSearchPathDirectory.CachesDirectory), Constants.HARDCODED_APP_NAME);

            IOPath.DirCreateByNotExists(appDataPath);
            IOPath.DirCreateByNotExists(cachePath);
            InitFileSystem(GetAppDataDirectory, GetCacheDirectory);
            string GetAppDataDirectory() => appDataPath;
            string GetCacheDirectory() => cachePath;
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 获取文件夹路径,返回的路径必定存在
        /// </summary>
        /// <param name="folder"></param>
        /// <returns></returns>
        public static string GetPath(this AppFolder folder)
        {
            var path1 = folder switch
            {
                AppFolder.Images or AppFolder.Cache => IOPath.CacheDirectory,
                AppFolder.Database => IOPath.AppDataDirectory,
                _ => throw new ArgumentOutOfRangeException(nameof(folder), folder, null),
            };
            var path = Path.Combine(path1, folder.ToString());

            IOPath.DirCreateByNotExists(path);
            return(path);
        }