GPAL - Generally Positive Automation Library v1.0
GPAL The Fluent Automation LIbrary
Loading...
Searching...
No Matches
GenerallyPositive.FileHelper Class Reference

File-side plumbing behind the fluent chain: writing a unit of work's data out in a delimited format, resolving where each browser actually downloads to, tokenizing input files, and the path handling the rest of the library leans on.
Most of this is internal. The members exposed here are the ones a workflow has a legitimate reason to call directly, mainly to find out where a download will land before going to fetch it. More...

Static Public Member Functions

static string GetDefaultDownloadDirectory (IBrowser browser)
 Returns the download directory this browser will actually use, read out of its own configuration rather than assumed. Routes to the Chrome, Edge or Firefox reader according to the browser type, and falls back to the Windows Downloads folder for anything else.
static string GetChromeDefaultDownloadDirectory (string profilePath=null)
 Reads Chrome's download.default_directory out of the profile's Preferences file. Falls back to the Windows Downloads folder when the preference was never set explicitly or the file cannot be found.
static string GetEdgeDefaultDownloadDirectory (string profilePath=null)
 Reads Edge's download.default_directory out of the profile's Preferences file. Edge is Chromium, so the preference lives in the same place, only under a different vendor directory. Falls back to the Windows Downloads folder when the preference was never set explicitly or the file cannot be found.
static string GetFirefoxDefaultDownloadDirectory (string profilePath=null)
 Reads Firefox's browser.download.dir out of the profile's prefs.js. Firefox keeps no JSON preferences file, so the default profile is found by parsing profiles.ini and the setting is read from prefs.js. Falls back to the Windows Downloads folder when the preference was never set explicitly.
static string GetShortPath (string longPath)
 Returns the 8.3 short form of a path, for the places that still cannot cope with spaces or a long path. The path has to exist, since Windows derives the short name from the filesystem. Hands back the original path unchanged when there is no short form.
static string EnsureDirectoryEndsWithBackslash (string directoryPath)
 Adds a trailing backslash to a directory path when it does not already have one, so the path can be concatenated without producing a double separator or gluing the directory to the filename.

Detailed Description

File-side plumbing behind the fluent chain: writing a unit of work's data out in a delimited format, resolving where each browser actually downloads to, tokenizing input files, and the path handling the rest of the library leans on.
Most of this is internal. The members exposed here are the ones a workflow has a legitimate reason to call directly, mainly to find out where a download will land before going to fetch it.

Definition at line 54 of file FileHelper.cs.

Member Function Documentation

◆ EnsureDirectoryEndsWithBackslash()

string GenerallyPositive.FileHelper.EnsureDirectoryEndsWithBackslash ( string directoryPath)
static

Adds a trailing backslash to a directory path when it does not already have one, so the path can be concatenated without producing a double separator or gluing the directory to the filename.

Parameters
directoryPathDirectory path to check
Returns
The path, guaranteed to end in a backslash

Definition at line 2245 of file FileHelper.cs.

◆ GetChromeDefaultDownloadDirectory()

string GenerallyPositive.FileHelper.GetChromeDefaultDownloadDirectory ( string profilePath = null)
static

Reads Chrome's download.default_directory out of the profile's Preferences file. Falls back to the Windows Downloads folder when the preference was never set explicitly or the file cannot be found.

Parameters
profilePathProfile directory to read. The Default profile under Local AppData when null
Returns
The configured download directory, or the Windows Downloads folder

Definition at line 877 of file FileHelper.cs.

◆ GetDefaultDownloadDirectory()

string GenerallyPositive.FileHelper.GetDefaultDownloadDirectory ( IBrowser browser)
static

Returns the download directory this browser will actually use, read out of its own configuration rather than assumed. Routes to the Chrome, Edge or Firefox reader according to the browser type, and falls back to the Windows Downloads folder for anything else.

Parameters
browserBrowser whose configured download directory is wanted
Returns
The download directory, ending in a backslash for the Windows fallback

Definition at line 858 of file FileHelper.cs.

◆ GetEdgeDefaultDownloadDirectory()

string GenerallyPositive.FileHelper.GetEdgeDefaultDownloadDirectory ( string profilePath = null)
static

Reads Edge's download.default_directory out of the profile's Preferences file. Edge is Chromium, so the preference lives in the same place, only under a different vendor directory. Falls back to the Windows Downloads folder when the preference was never set explicitly or the file cannot be found.

Parameters
profilePathProfile directory to read. The Default profile under Local AppData when null
Returns
The configured download directory, or the Windows Downloads folder

Definition at line 917 of file FileHelper.cs.

◆ GetFirefoxDefaultDownloadDirectory()

string GenerallyPositive.FileHelper.GetFirefoxDefaultDownloadDirectory ( string profilePath = null)
static

Reads Firefox's browser.download.dir out of the profile's prefs.js. Firefox keeps no JSON preferences file, so the default profile is found by parsing profiles.ini and the setting is read from prefs.js. Falls back to the Windows Downloads folder when the preference was never set explicitly.

Parameters
profilePathProfile directory to read. Resolved from profiles.ini when null
Returns
The configured download directory, or the Windows Downloads folder

Definition at line 958 of file FileHelper.cs.

◆ GetShortPath()

string GenerallyPositive.FileHelper.GetShortPath ( string longPath)
static

Returns the 8.3 short form of a path, for the places that still cannot cope with spaces or a long path. The path has to exist, since Windows derives the short name from the filesystem. Hands back the original path unchanged when there is no short form.

Parameters
longPathPath to shorten
Returns
The short path, or longPath when Windows did not supply one

Definition at line 1877 of file FileHelper.cs.


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