C# Class GitForce.ClassUtils

Contains various utility functions
Datei anzeigen Open project: gdevic/GitForce Class Usage Examples

Public Methods

Method Description
AddEnvar ( string name, string value ) : void

Adds an environment variable for the Run method

CommandPromptHere ( string where ) : void

Open a command prompt at the specific directory

DeleteFile ( string name ) : bool

Deletes a file from the local file system. Returns true if delete succeeded, false otherwise.

DeleteFolder ( DirectoryInfo dirInfo, bool fPreserveGit, bool fPreserveRootFolder ) : bool

Remove given folder and all files and subfolders under it. If fPreserveGit is true, all folders that are named ".git" will be preserved (not removed) If fPreserveRootFolder is true, the first (root) folder will also be preserved Return false if the function could not remove all folders, true otherwise.

DirStat ( string path ) : DirStatType

Given a fully qualified path to a local directory, return the stat on that folder

ExecuteShellCommand ( string cmd, string args ) : string

Executes a shell command

ExplorerHere ( string where, string selFile ) : void

Open a file browser/Explorer at the specific directory, optionally selecting a file

FileDoubleClick ( string file ) : void

Handle double-clicking on a file. Depending on the saved options, we either do nothing ("0"), open a file using a default Explorer file association ("1"), or open a file using a specified application ("2")

FileOpenFromMenu ( object sender, string file ) : void

Edit selected file using either the default editor (native OS file association, if the tag is null, or the editor program specified in the tag field. This is a handler for the context menu, edit tool bar button and also revision history view menus.

GetEnvars ( ) : string>.Dictionary

Returns a set of environment variables registered for this execution environment

GetHomePath ( ) : string

Retruns a path to the home directory.

GetShellExecCmd ( ) : string

Returns CMD/SHELL executable name to execute a command line command

GetShellExecFlags ( ) : string

Returns a string to be used by CMD/SHELL as argument when executing a command line command

GetShortPathName ( string path ) : string

This function is meaningful only on Windows: Given a long file path name, return its short version. This is used mainly to avoid various problems with paths containing spaces and the inability of git to handle them.

IsMono ( ) : bool

Returns true if the app is running on Mono (Linux), false if it is Windows

IsNullOrWhiteSpace ( string s ) : bool

Identical to NET4.0 IsNullOrWhiteSpace()

OpenWebLink ( string html ) : void

Open an HTML link in an external web browser application.

ToPlainAscii ( string s ) : string

Returns a copy of the input string, but with all non-ASCII characters stripped down. This function also removes ANSI escape codes from the string.

UpgradeApplicationSettingsIfNecessary ( ) : void

Upgrades the application settings to a new version, if necessary http://stackoverflow.com/questions/10121044/app-loses-all-settings-when-app-update-is-installed

WriteResourceToFile ( string pathName, string fileName, byte buffer ) : string

Writes binary resource to a temporary file

Private Methods

Method Description
DeleteFolder ( DirectoryInfo dirInfo ) : bool

Deletes a folder from the local file system. Returns true if delete succeeded, false otherwise.

Method Details

AddEnvar() public static method

Adds an environment variable for the Run method
public static AddEnvar ( string name, string value ) : void
name string
value string
return void

CommandPromptHere() public static method

Open a command prompt at the specific directory
public static CommandPromptHere ( string where ) : void
where string
return void

DeleteFile() public static method

Deletes a file from the local file system. Returns true if delete succeeded, false otherwise.
public static DeleteFile ( string name ) : bool
name string
return bool

DeleteFolder() public static method

Remove given folder and all files and subfolders under it. If fPreserveGit is true, all folders that are named ".git" will be preserved (not removed) If fPreserveRootFolder is true, the first (root) folder will also be preserved Return false if the function could not remove all folders, true otherwise.
public static DeleteFolder ( DirectoryInfo dirInfo, bool fPreserveGit, bool fPreserveRootFolder ) : bool
dirInfo System.IO.DirectoryInfo
fPreserveGit bool
fPreserveRootFolder bool
return bool

DirStat() public static method

Given a fully qualified path to a local directory, return the stat on that folder
public static DirStat ( string path ) : DirStatType
path string
return DirStatType

ExecuteShellCommand() public static method

Executes a shell command
public static ExecuteShellCommand ( string cmd, string args ) : string
cmd string
args string
return string

ExplorerHere() public static method

Open a file browser/Explorer at the specific directory, optionally selecting a file
public static ExplorerHere ( string where, string selFile ) : void
where string
selFile string
return void

FileDoubleClick() public static method

Handle double-clicking on a file. Depending on the saved options, we either do nothing ("0"), open a file using a default Explorer file association ("1"), or open a file using a specified application ("2")
public static FileDoubleClick ( string file ) : void
file string
return void

FileOpenFromMenu() public static method

Edit selected file using either the default editor (native OS file association, if the tag is null, or the editor program specified in the tag field. This is a handler for the context menu, edit tool bar button and also revision history view menus.
public static FileOpenFromMenu ( object sender, string file ) : void
sender object
file string
return void

GetEnvars() public static method

Returns a set of environment variables registered for this execution environment
public static GetEnvars ( ) : string>.Dictionary
return string>.Dictionary

GetHomePath() public static method

Retruns a path to the home directory.
public static GetHomePath ( ) : string
return string

GetShellExecCmd() public static method

Returns CMD/SHELL executable name to execute a command line command
public static GetShellExecCmd ( ) : string
return string

GetShellExecFlags() public static method

Returns a string to be used by CMD/SHELL as argument when executing a command line command
public static GetShellExecFlags ( ) : string
return string

GetShortPathName() public static method

This function is meaningful only on Windows: Given a long file path name, return its short version. This is used mainly to avoid various problems with paths containing spaces and the inability of git to handle them.
public static GetShortPathName ( string path ) : string
path string
return string

IsMono() public static method

Returns true if the app is running on Mono (Linux), false if it is Windows
public static IsMono ( ) : bool
return bool

IsNullOrWhiteSpace() public static method

Identical to NET4.0 IsNullOrWhiteSpace()
public static IsNullOrWhiteSpace ( string s ) : bool
s string
return bool

OpenWebLink() public static method

Open an HTML link in an external web browser application.
public static OpenWebLink ( string html ) : void
html string
return void

ToPlainAscii() public static method

Returns a copy of the input string, but with all non-ASCII characters stripped down. This function also removes ANSI escape codes from the string.
public static ToPlainAscii ( string s ) : string
s string
return string

UpgradeApplicationSettingsIfNecessary() public static method

Upgrades the application settings to a new version, if necessary http://stackoverflow.com/questions/10121044/app-loses-all-settings-when-app-update-is-installed
public static UpgradeApplicationSettingsIfNecessary ( ) : void
return void

WriteResourceToFile() public static method

Writes binary resource to a temporary file
public static WriteResourceToFile ( string pathName, string fileName, byte buffer ) : string
pathName string
fileName string
buffer byte
return string