本文整理汇总了C#中IAbsoluteFilePath类的典型用法代码示例。如果您正苦于以下问题:C# IAbsoluteFilePath类的具体用法?C# IAbsoluteFilePath怎么用?C# IAbsoluteFilePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAbsoluteFilePath类属于命名空间,在下文中一共展示了IAbsoluteFilePath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Gzip
public virtual string Gzip(IAbsoluteFilePath file, IAbsoluteFilePath dest = null,
bool preserveFileNameAndModificationTime = true, ITProgress status = null) {
Contract.Requires<ArgumentNullException>(file != null);
Contract.Requires<ArgumentException>(file.Exists);
var defDest = (file + ".gz").ToAbsoluteFilePath();
if (dest == null)
dest = defDest;
var cmd = $"-f --best --rsyncable --keep \"{file}\"";
if (!preserveFileNameAndModificationTime)
cmd = "-n " + cmd;
dest.RemoveReadonlyWhenExists();
var startInfo =
new ProcessStartInfoBuilder(Common.Paths.ToolPath.GetChildFileWithName("gzip.exe"), cmd) {
WorkingDirectory = file.ParentDirectoryPath
}.Build();
var srcSize = file.FileInfo.Length;
ProcessExitResultWithOutput ret;
var predictedSize = srcSize*DefaultPredictedCompressionRatio;
using (StatusProcessor.Conditional(defDest, status, (long) predictedSize))
ret = ProcessManager.LaunchAndGrabTool(startInfo, "Gzip pack");
if (Path.GetFullPath(dest.ToString()) != Path.GetFullPath(defDest.ToString()))
FileUtil.Ops.MoveWithRetry(defDest, dest);
return ret.StandardOutput + ret.StandardError;
}
示例2: Import
public Package Import(Repository repo, IAbsoluteDirectoryPath workDir, IAbsoluteFilePath packageFilePath) {
var metaData = Package.Load(packageFilePath);
var package = new Package(workDir, metaData, repo);
package.Commit(metaData.GetVersionInfo());
return package;
}
示例3: TryDownloadAsync
async Task TryDownloadAsync(TransferSpec spec, IWebClient webClient, IAbsoluteFilePath tmpFile) {
try {
tmpFile.RemoveReadonlyWhenExists();
if (!string.IsNullOrWhiteSpace(spec.Uri.UserInfo))
webClient.SetAuthInfo(spec.Uri);
using (webClient.HandleCancellationToken(spec))
await webClient.DownloadFileTaskAsync(spec.Uri, tmpFile.ToString()).ConfigureAwait(false);
VerifyIfNeeded(spec, tmpFile);
_fileOps.Move(tmpFile, spec.LocalFile);
} catch (OperationCanceledException e) {
_fileOps.DeleteIfExists(tmpFile.ToString());
throw CreateTimeoutException(spec, e);
} catch (WebException ex) {
_fileOps.DeleteIfExists(tmpFile.ToString());
var cancelledEx = ex.InnerException as OperationCanceledException;
if (cancelledEx != null)
throw CreateTimeoutException(spec, cancelledEx);
if (ex.Status == WebExceptionStatus.RequestCanceled)
throw CreateTimeoutException(spec, ex);
var response = ex.Response as HttpWebResponse;
if (response == null)
throw GenerateDownloadException(spec, ex);
switch (response.StatusCode) {
case HttpStatusCode.NotFound:
throw new RequestFailedException("Received a 404: NotFound response", ex);
case HttpStatusCode.Forbidden:
throw new RequestFailedException("Received a 403: Forbidden response", ex);
case HttpStatusCode.Unauthorized:
throw new RequestFailedException("Received a 401: Unauthorized response", ex);
}
throw GenerateDownloadException(spec, ex);
}
}
示例4: UnpackFile
public virtual void UnpackFile(IAbsoluteFilePath srcFile, IAbsoluteFilePath dstFile, IStatus status = null) {
var dstPath = dstFile.ParentDirectoryPath;
dstPath.MakeSurePathExists();
dstFile.RemoveReadonlyWhenExists();
Tools.Compression.Unpack(srcFile, dstPath, true, progress: status);
}
示例5: GetUpdateExe
public static IAbsoluteFilePath GetUpdateExe(IAbsoluteFilePath location) {
var parent = location.ParentDirectoryPath;
var updateExe = parent.HasParentDirectory
? parent.ParentDirectoryPath.GetChildFileWithName("Update.exe")
: null;
return updateExe;
}
示例6: TryResolve
public VariablePathResolvingStatus TryResolve(IEnumerable<KeyValuePair<string, string>> variables, out IAbsoluteFilePath resolvedPath,
out IReadOnlyList<string> unresolvedVariables)
{
Argument.IsNotNull(nameof(variables), variables);
string path;
if (!TryResolve(variables, out path, out unresolvedVariables))
{
resolvedPath = null;
return VariablePathResolvingStatus.UnresolvedVariable;
}
if (!path.IsValidAbsoluteFilePath())
{
resolvedPath = null;
return VariablePathResolvingStatus.CannotConvertToAbsolutePath;
}
resolvedPath = path.ToAbsoluteFilePath();
return VariablePathResolvingStatus.Success;
}
示例7: SafeSave
public static void SafeSave(Action<IAbsoluteFilePath> saveCode, IAbsoluteFilePath filePath) {
var newFileName = (filePath + GenericTools.TmpExtension).ToAbsoluteFilePath();
saveCode(newFileName);
FileUtil.Ops.Copy(newFileName, filePath);
FileUtil.Ops.DeleteFile(newFileName);
}
示例8: ProcessDll
void ProcessDll(IAbsoluteFilePath dll, bool force = true) {
var fileName = dll.FileName.ToLower();
var ts332Path = _localMachineInfo.TS3_32_Path;
var ts364Path = _localMachineInfo.TS3_64_Path;
switch (fileName) {
case "task_force_radio_win32.dll": {
InstallTaskForceRadio(dll, ts332Path, force);
break;
}
case "task_force_radio_win64.dll": {
InstallTaskForceRadio(dll, ts364Path, force);
break;
}
case "dsound.dll": {
var path = _game.InstalledState.Directory;
if (path != null)
InstallDll(dll, path, null, force);
break;
}
default: {
if (ts332Dlls.Contains(fileName))
InstallTs3Plugin(dll, ts332Path, force);
else if (ts364Dlls.Contains(fileName))
InstallTs3Plugin(dll, ts364Path, force);
break;
}
}
}
示例9: CreateDesktopPwsIconCustomRepo
public static Task CreateDesktopPwsIconCustomRepo(string name, string description, Uri target,
IAbsoluteFilePath icon = null) => CreateShortcutAsync(new ShortcutInfo(GetDesktop(), name,
Common.Paths.EntryLocation) {
Arguments = target.ToString(),
Description = description,
Icon = icon
});
示例10: MultiMirrorFileDownloadSpec
public MultiMirrorFileDownloadSpec(string remoteFile, IAbsoluteFilePath localFile) {
Contract.Requires<ArgumentNullException>(remoteFile != null);
Contract.Requires<ArgumentNullException>(localFile != null);
Contract.Requires<ArgumentException>(!remoteFile.Contains(@"\"));
RemoteFile = remoteFile;
LocalFile = localFile;
}
示例11: CreateDesktopGameBat
public static Task CreateDesktopGameBat(string name, string description, string arguments, Game game,
IAbsoluteFilePath icon = null) {
return
Tools.FileUtil.CreateBatFile(GetDesktop(), name,
GenerateBatContent(game.InstalledState.LaunchExecutable, game.InstalledState.Directory, arguments));
// TODO: DEscription etc? Maybe just create a nice shortcut to this thing incl icon?
}
示例12: GenerateCommandLineExecution
public static IEnumerable<string> GenerateCommandLineExecution(IAbsoluteFilePath location, string executable,
params string[] desiredParams) {
var updateExe = GetUpdateExe(location);
return (updateExe != null) && updateExe.Exists
? new[] {updateExe.ToString()}.Concat(Restarter.BuildUpdateExeArguments(executable, desiredParams))
: new[] {location.ToString()}.Concat(desiredParams);
}
示例13: CreateDesktopPwsIcon
public static Task CreateDesktopPwsIcon(string name, string description, string arguments,
IAbsoluteFilePath icon = null) => CreateShortcutAsync(new ShortcutInfo(GetDesktop(), name,
Common.Paths.EntryLocation) {
Arguments = arguments,
Icon = icon,
Description = description
});
示例14: Gzip
public virtual string Gzip(IAbsoluteFilePath file, IAbsoluteFilePath dest = null,
bool preserveFileNameAndModificationTime = false) {
Contract.Requires<ArgumentNullException>(file != null);
Contract.Requires<ArgumentException>(file.Exists);
var defDest = (file + ".gz").ToAbsoluteFilePath();
if (dest == null)
dest = defDest;
var cmd = String.Format("-f --best --rsyncable --keep \"{0}\"", file);
if (!preserveFileNameAndModificationTime)
cmd = "-n " + cmd;
dest.RemoveReadonlyWhenExists();
var startInfo =
new ProcessStartInfoBuilder(Common.Paths.ToolPath.GetChildFileWithName("gzip.exe"), cmd) {
WorkingDirectory = file.ParentDirectoryPath.ToString()
}.Build();
var ret = ProcessManager.LaunchAndGrabTool(startInfo, "Gzip pack");
if (Path.GetFullPath(dest.ToString()) != Path.GetFullPath(defDest.ToString()))
FileUtil.Ops.MoveWithRetry(defDest, dest);
return ret.StandardOutput + ret.StandardError;
}
示例15: TryCheckUac
async Task<bool> TryCheckUac(IAbsoluteDirectoryPath mp, IAbsoluteFilePath path) {
Exception ex;
try {
mp.MakeSurePathExists();
if (path.Exists)
File.Delete(path.ToString());
using (File.CreateText(path.ToString())) {}
File.Delete(path.ToString());
return false;
} catch (UnauthorizedAccessException e) {
ex = e;
} catch (Exception e) {
this.Logger().FormattedWarnException(e);
return false;
}
var report = await UserErrorHandler.HandleUserError(new UserErrorModel("Restart the application elevated?",
$"The application failed to write to the path, probably indicating permission issues\nWould you like to restart the application Elevated?\n\n {mp}",
RecoveryCommands.YesNoCommands, null, ex)) == RecoveryOptionResultModel.RetryOperation;
if (!report)
return false;
RestartWithUacInclEnvironmentCommandLine();
return true;
}