Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved check for 2 files whether they are different, now also using…
… the size of the files.
- Loading branch information
Amit Apple
committed
Dec 5, 2012
1 parent
2800e41
commit 9c9213b
Showing
6 changed files
with
63 additions
and
25 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
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,17 +1,37 @@ | ||
///<reference path='fileInfoBase.ts'/> | ||
|
||
class FileInfo extends FileInfoBase { | ||
private _modifiedTime: Date; | ||
private _fileStat: FileStat; | ||
|
||
constructor (path: string, modifiedTime: Date) { | ||
constructor (path: string, fileStat: FileStat) { | ||
super(path); | ||
|
||
Ensure.argNotNull(modifiedTime, "modifiedTime"); | ||
Ensure.argNotNull(fileStat, "fileStat"); | ||
|
||
this._modifiedTime = modifiedTime; | ||
this._fileStat = fileStat; | ||
} | ||
|
||
modifiedTime() { | ||
return this._modifiedTime; | ||
return this._fileStat.mtime; | ||
} | ||
|
||
size() { | ||
return this._fileStat.size; | ||
} | ||
} | ||
|
||
function fileEquals(file1: FileInfo, file2: FileInfo) { | ||
if (file1 == null) { | ||
return file2 == null; | ||
} | ||
|
||
if (file1.modifiedTime() == null) { | ||
return file2.modifiedTime() == null; | ||
} | ||
|
||
return | ||
file2 != null && | ||
file2.modifiedTime() != null && | ||
file1.modifiedTime().getTime() === file2.modifiedTime().getTime() && | ||
file1.size === file2.size; | ||
} |
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
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