fCraft  0.638
Custom Minecraft Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events
fCraft.Paths Class Reference

Contains fCraft path settings, and some filesystem-related utilities. More...

Static Public Member Functions

static void MoveOrReplaceFile ([NotNull] string source,[NotNull] string destination)
 Moves file from source to destination, overwriting destination if it exists, as safely as possible. File.Replace, File.Copy/File.Delete, or File.Move is used depending on circumstances.
 
static bool TestDirectory ([NotNull] string pathLabel,[NotNull] string path, bool checkForWriteAccess)
 Makes sure that the path format is valid, that it exists, that it is accessible and writeable.
 
static bool TestFile ([NotNull] string fileLabel,[NotNull] string fileName, bool createIfDoesNotExist, FileAccess neededAccess)
 Makes sure that the path format is valid, and optionally whether it is readable/writeable.
 
static bool Compare ([NotNull] string path1,[NotNull] string path2)
 Checks whether two paths/file names reference the exact same filesystem location. Accounts for filesystem quirks.
 
static bool Compare ([NotNull] string path1,[NotNull] string path2, bool caseSensitive)
 Checks whether two paths/file names reference the exact same filesystem location. Allows specifying whether comparison should be case-sensitive or not.
 
static bool IsValidPath (string path)
 Checks whether the given path is valid. Does NOT check for existence of the file/directory at the given path.
 
static bool Contains ([NotNull] string parentPath,[NotNull] string childPath)
 Checks whether childPath is inside parentPath. Accounts for filesystem quirks.
 
static bool Contains ([NotNull] string parentPath,[NotNull] string childPath, bool caseSensitive)
 Checks whether childPath is inside parentPath.
 
static bool FileExists ([NotNull] string fileName, bool caseSensitive)
 Checks whether the file exists in a specified way (case-sensitive or case-insensitive)
 
static bool Exists ([NotNull] this FileInfo fileInfo, bool caseSensitive)
 Checks whether the file exists in a specified way (case-sensitive or case-insensitive).
 
static string GetDirectoryNameOrRoot ([NotNull] string fileOrDirName)
 Gets full directory name for a given path, or path root for directory-less paths. Uses either Path.GetDirectoryName or Path.GetPathRoot to get the result.
 
static void ForceRename ([NotNull] string originalFullFileName,[NotNull] string newFileName)
 Allows making changes to file name capitalization on case-insensitive filesystems.
 
static FileInfo[] FindFiles ([NotNull] string fullFileName)
 Find files that match the name in a case-insensitive way.
 
static bool IsProtectedFileName ([NotNull] string fileName)
 Checks whether the given file is on a list of protected file names. Protected file names include all fCraft binaries, configuration files, and data files.
 

Public Attributes

const string MapPathDefault = "maps"
 
const string PlayerDBFileName = "PlayerDB.txt"
 
const string IPBanListFileName = "ipbans.txt"
 
const string GreetingFileName = "greeting.txt"
 
const string AnnouncementsFileName = "announcements.txt"
 
const string RulesFileName = "rules.txt"
 
const string RulesDirectory = "rules"
 
const string HeartbeatDataFileName = "heartbeatdata.txt"
 
const string UpdaterFileName = "UpdateInstaller.exe"
 
const string WorldListFileName = "worlds.xml"
 
const string AutoRankFileName = "autorank.xml"
 
const string BlockDBDirectory = "blockdb"
 
const string DataBackupDirectory = "databackups"
 
const string DataBackupFileNameFormat = "fCraftData_{0:yyyyMMdd'_'HH'-'mm'-'ss}.zip"
 

Static Public Attributes

static readonly string WorkingPathDefault
 

Properties

static bool IgnoreMapPathConfigKey [get, set]
 Whether fCraft should parse ConfigKey.MapPath when loading config.xml This is set to "false" by Server if –mappath command-line argument was given.
 
static string MapPath [get, set]
 Path to save maps to (default: .) Can be overridden at startup via command-line argument "–mappath=", or via "MapPath" ConfigKey
 
static string WorkingPath [get, set]
 Working path (default: whatever directory fCraft.dll is located in) Can be overridden at startup via command line argument "–path="
 
static string LogPath [get, set]
 Path to save logs to (default: .) Can be overridden at startup via command-line argument "–logpath="
 
static string ConfigFileName [get, set]
 Path to load/save config to/from (default: ..xml) Can be overridden at startup via command-line argument "–config="
 
static string BlockDBPath [get]
 Directory where block database files (.fbdb) are stored.
 
static string RulesPath [get]
 Directory where rule sections are stored.
 
static string BackupPath [get]
 Path where map backups are stored.
 

Detailed Description

Contains fCraft path settings, and some filesystem-related utilities.

Member Function Documentation

static bool fCraft.Paths.Compare ( [NotNull] string  path1,
[NotNull] string  path2 
)
static

Checks whether two paths/file names reference the exact same filesystem location. Accounts for filesystem quirks.

Returns
True if given paths are referencing the same file. False if they're not.
Exceptions
ArgumentNullExceptionpath1 or path2 is null.
static bool fCraft.Paths.Compare ( [NotNull] string  path1,
[NotNull] string  path2,
bool  caseSensitive 
)
static

Checks whether two paths/file names reference the exact same filesystem location. Allows specifying whether comparison should be case-sensitive or not.

Returns
True if given paths are referencing the same file. False if they're not.
Exceptions
ArgumentNullExceptionpath1 or path2 is null.
static bool fCraft.Paths.Contains ( [NotNull] string  parentPath,
[NotNull] string  childPath 
)
static

Checks whether childPath is inside parentPath. Accounts for filesystem quirks.

Parameters
parentPathPath that is supposed to contain childPath.
childPathPath that is supposed to be contained within parentPath.
Returns
True if childPath is contained within parentPath.
static bool fCraft.Paths.Contains ( [NotNull] string  parentPath,
[NotNull] string  childPath,
bool  caseSensitive 
)
static

Checks whether childPath is inside parentPath.

Parameters
parentPathPath that is supposed to contain childPath.
childPathPath that is supposed to be contained within parentPath.
caseSensitiveWhether check should be case-sensitive or case-insensitive.
Returns
True if childPath is contained within parentPath.
static bool fCraft.Paths.Exists ( [NotNull] this FileInfo  fileInfo,
bool  caseSensitive 
)
static

Checks whether the file exists in a specified way (case-sensitive or case-insensitive).

Parameters
fileInfoFileInfo object in question.
caseSensitiveWhether check should be case-sensitive or case-insensitive.
Returns
True if file exists, otherwise false.
Exceptions
ArgumentNullExceptionfileInfo is null.
static bool fCraft.Paths.FileExists ( [NotNull] string  fileName,
bool  caseSensitive 
)
static

Checks whether the file exists in a specified way (case-sensitive or case-insensitive)

Parameters
fileNameFile name/path to check.
caseSensitiveWhether check should be case-sensitive or case-insensitive.
Returns
True if file exists, otherwise false.
static FileInfo [] fCraft.Paths.FindFiles ( [NotNull] string  fullFileName)
static

Find files that match the name in a case-insensitive way.

Parameters
fullFileNameCase-insensitive file name to look for.
Returns
Array of matches. Empty array if no files matches.
Exceptions
ArgumentNullExceptionfullFileName is null.
static void fCraft.Paths.ForceRename ( [NotNull] string  originalFullFileName,
[NotNull] string  newFileName 
)
static

Allows making changes to file name capitalization on case-insensitive filesystems.

Parameters
originalFullFileNameFull path to the original file name
newFileNameNew file name (do not include the full path)
Exceptions
ArgumentNullExceptionoriginalFullFileName or newFileName is null.
static string fCraft.Paths.GetDirectoryNameOrRoot ( [NotNull] string  fileOrDirName)
static

Gets full directory name for a given path, or path root for directory-less paths. Uses either Path.GetDirectoryName or Path.GetPathRoot to get the result.

Exceptions
ArgumentNullExceptionfileOrDirName is null.
static bool fCraft.Paths.IsProtectedFileName ( [NotNull] string  fileName)
static

Checks whether the given file is on a list of protected file names. Protected file names include all fCraft binaries, configuration files, and data files.

Parameters
fileNameFile name/path to check.
Returns
True if given file name is considered protected; otherwise false.
Exceptions
ArgumentNullExceptionfileName is null.
static bool fCraft.Paths.IsValidPath ( string  path)
static

Checks whether the given path is valid. Does NOT check for existence of the file/directory at the given path.

Parameters
pathPath to check.
Returns
Returns false if path is of incorrect format, too long, unsupported, or blocked. Otherwise true.
static void fCraft.Paths.MoveOrReplaceFile ( [NotNull] string  source,
[NotNull] string  destination 
)
static

Moves file from source to destination, overwriting destination if it exists, as safely as possible. File.Replace, File.Copy/File.Delete, or File.Move is used depending on circumstances.

Parameters
sourceFile to be moved.
destinationDestination file name. If this file exists, it will be replaced.
Exceptions
ArgumentNullExceptionsource or destination is used.
static bool fCraft.Paths.TestDirectory ( [NotNull] string  pathLabel,
[NotNull] string  path,
bool  checkForWriteAccess 
)
static

Makes sure that the path format is valid, that it exists, that it is accessible and writeable.

Parameters
pathLabelName of the path that's being tested (e.g. "map path"). Used for logging.
pathFull or partial path.
checkForWriteAccessIf set, tries to write to the given directory.
Returns
Full path of the directory (on success) or null (on failure).
Exceptions
ArgumentNullExceptionpathLabel or path is null.
static bool fCraft.Paths.TestFile ( [NotNull] string  fileLabel,
[NotNull] string  fileName,
bool  createIfDoesNotExist,
FileAccess  neededAccess 
)
static

Makes sure that the path format is valid, and optionally whether it is readable/writeable.

Parameters
fileLabelName of the path that's being tested (e.g. "map path"). Used for logging.
fileNameFull or partial path of the file.
createIfDoesNotExistIf target file is missing and this option is OFF, TestFile returns true. If target file is missing and this option is ON, TestFile tries to create a file and returns whether it succeeded.
neededAccessIf file is present, type of access to test.
Returns
Whether target file passed all tests.
Exceptions
ArgumentNullExceptionfileLabel or fileName is null.

Member Data Documentation

const string fCraft.Paths.AnnouncementsFileName = "announcements.txt"
const string fCraft.Paths.AutoRankFileName = "autorank.xml"
const string fCraft.Paths.BlockDBDirectory = "blockdb"
const string fCraft.Paths.DataBackupDirectory = "databackups"
const string fCraft.Paths.DataBackupFileNameFormat = "fCraftData_{0:yyyyMMdd'_'HH'-'mm'-'ss}.zip"
const string fCraft.Paths.GreetingFileName = "greeting.txt"
const string fCraft.Paths.HeartbeatDataFileName = "heartbeatdata.txt"
const string fCraft.Paths.IPBanListFileName = "ipbans.txt"
const string fCraft.Paths.MapPathDefault = "maps"
const string fCraft.Paths.PlayerDBFileName = "PlayerDB.txt"
const string fCraft.Paths.RulesDirectory = "rules"
const string fCraft.Paths.RulesFileName = "rules.txt"
const string fCraft.Paths.UpdaterFileName = "UpdateInstaller.exe"
readonly string fCraft.Paths.WorkingPathDefault
static
const string fCraft.Paths.WorldListFileName = "worlds.xml"

Property Documentation

string fCraft.Paths.BackupPath
staticget

Path where map backups are stored.

string fCraft.Paths.BlockDBPath
staticget

Directory where block database files (.fbdb) are stored.

string fCraft.Paths.ConfigFileName
staticgetset

Path to load/save config to/from (default: ..xml) Can be overridden at startup via command-line argument "–config="

bool fCraft.Paths.IgnoreMapPathConfigKey
staticgetset

Whether fCraft should parse ConfigKey.MapPath when loading config.xml This is set to "false" by Server if –mappath command-line argument was given.

string fCraft.Paths.LogPath
staticgetset

Path to save logs to (default: .) Can be overridden at startup via command-line argument "–logpath="

string fCraft.Paths.MapPath
staticgetset

Path to save maps to (default: .) Can be overridden at startup via command-line argument "–mappath=", or via "MapPath" ConfigKey

string fCraft.Paths.RulesPath
staticget

Directory where rule sections are stored.

string fCraft.Paths.WorkingPath
staticgetset

Working path (default: whatever directory fCraft.dll is located in) Can be overridden at startup via command line argument "–path="


The documentation for this class was generated from the following file: