Example #1
0
        /// <summary>
        /// Gets the <see cref="FileInfo"/> for the target file.
        /// </summary>
        /// <returns>the file to write to</returns>
        protected override FileInfo GetFileInfo()
        {
            var logsDir = new DirectoryInfo(Path.Combine("Logs", mainName, name));

            logsDir.Create();
            var finfo = new FileInfo(Path.Combine(logsDir.FullName, $"{Utils.CurrentTime():yyyy.MM.dd.HH.mm.ss}.log"));

            return(finfo);
        }
Example #2
0
        /// <summary>
        /// Returns true if <paramref name="path"/> starts with the path <paramref name="baseDirPath"/>.
        /// The comparison is case-insensitive, handles / and \ slashes as folder separators and
        /// only matches if the base dir folder name is matched exactly ("c:\foobar\file.txt" is not a sub path of "c:\foo").
        /// </summary>
        public static bool IsSubPathOf(this string path, string baseDirPath)
        {
            string normalizedPath = Path.GetFullPath(path.Replace('/', '\\')
                                                     .WithEnding("\\"));

            string normalizedBaseDirPath = Path.GetFullPath(baseDirPath.Replace('/', '\\')
                                                            .WithEnding("\\"));

            return(normalizedPath.StartsWith(normalizedBaseDirPath, StringComparison.OrdinalIgnoreCase));
        }
 private ModPrefs()
 {
     _instance = new IniFile(Path.Combine(Environment.CurrentDirectory, "UserData", "modprefs.ini"));
 }
 /// <summary>
 /// Constructs a ModPrefs object for the provide plugin.
 /// </summary>
 /// <param name="plugin">the plugin to get the preferences file for</param>
 public ModPrefs(PluginMetadata plugin)
 {
     _instance = new IniFile(Path.Combine(Environment.CurrentDirectory, "UserData", "ModPrefs",
                                          $"{plugin.Name}.ini"));
 }