forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
294 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Cosmos.Build.Installer; | ||
|
||
namespace Cosmos.Build.Builder { | ||
public class FileMgr : IDisposable { | ||
public string SrcPath; | ||
public string DestPath; | ||
|
||
public FileMgr(string aSrcPath, string aDestPath) { | ||
SrcPath = aSrcPath; | ||
DestPath = aDestPath; | ||
} | ||
|
||
public void ResetReadOnly(string aPathname) { | ||
var xAttrib = File.GetAttributes(aPathname); | ||
if ((xAttrib & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { | ||
File.SetAttributes(aPathname, xAttrib & ~FileAttributes.ReadOnly); | ||
} | ||
} | ||
namespace Cosmos.Build.Builder | ||
{ | ||
internal class FileMgr : IDisposable | ||
{ | ||
private string _srcPath; | ||
private string _destPath; | ||
private ILogger _logger; | ||
|
||
public void Copy(string aSrcPathname, bool aClearReadonly = true) { | ||
Copy(aSrcPathname, Path.GetFileName(aSrcPathname), aClearReadonly); | ||
} | ||
public void Copy(string aSrcPathname, string aDestPathname, bool aClearReadonly = true) { | ||
Log.WriteLine("Copy"); | ||
|
||
string xSrc = Path.Combine(SrcPath, aSrcPathname); | ||
Log.WriteLine(" From: " + xSrc); | ||
|
||
string xDest = Path.Combine(DestPath, aDestPathname); | ||
Log.WriteLine(" To: " + xDest); | ||
|
||
// Copying files that are in TFS often they will be read only, so need to kill this file before copy | ||
// We don't use TFS any more.. but left the code. | ||
if (aClearReadonly && File.Exists(xDest)) { | ||
ResetReadOnly(xDest); | ||
} | ||
File.Copy(xSrc, xDest, true); | ||
ResetReadOnly(xDest); | ||
} | ||
public FileMgr(ILogger logger, string srcPath, string destPath) | ||
{ | ||
_srcPath = srcPath; | ||
_destPath = destPath; | ||
_logger = logger; | ||
} | ||
|
||
// Dummy pattern to allow scoping via using. | ||
// Hacky, but for what we are doing its fine and the GC | ||
// effects are negligible in our usage. | ||
protected virtual void Dispose(bool aDisposing) { | ||
} | ||
public void ResetReadOnly(string aPathname) | ||
{ | ||
var xAttrib = File.GetAttributes(aPathname); | ||
if ((xAttrib & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) | ||
{ | ||
File.SetAttributes(aPathname, xAttrib & ~FileAttributes.ReadOnly); | ||
} | ||
} | ||
|
||
public void Dispose() { | ||
Dispose(true); | ||
} | ||
public void Copy(string aSrcPathname, bool aClearReadonly = true) | ||
{ | ||
Copy(aSrcPathname, Path.GetFileName(aSrcPathname), aClearReadonly); | ||
} | ||
public void Copy(string aSrcPathname, string aDestPathname, bool aClearReadonly = true) | ||
{ | ||
_logger.LogMessage("Copy"); | ||
|
||
} | ||
string xSrc = Path.Combine(_srcPath, aSrcPathname); | ||
_logger.LogMessage(" From: " + xSrc); | ||
|
||
string xDest = Path.Combine(_destPath, aDestPathname); | ||
_logger.LogMessage(" To: " + xDest); | ||
|
||
// Copying files that are in TFS often they will be read only, so need to kill this file before copy | ||
// We don't use TFS any more.. but left the code. | ||
if (aClearReadonly && File.Exists(xDest)) | ||
{ | ||
ResetReadOnly(xDest); | ||
} | ||
File.Copy(xSrc, xDest, true); | ||
ResetReadOnly(xDest); | ||
} | ||
|
||
// Dummy pattern to allow scoping via using. | ||
// Hacky, but for what we are doing its fine and the GC | ||
// effects are negligible in our usage. | ||
protected virtual void Dispose(bool aDisposing) | ||
{ | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Cosmos.Build.Builder | ||
{ | ||
internal interface ILogger | ||
{ | ||
void NewSection(string name); | ||
void LogMessage(string text); | ||
void SetError(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.