Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
562efc7d
Commit
562efc7d
authored
5 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Add DirectoryDetails class to investigate dirs in the grace location
Refers to
#20
parent
0127a501
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ATxCommon/ATxCommon.csproj
+1
-0
1 addition, 0 deletions
ATxCommon/ATxCommon.csproj
ATxCommon/DirectoryDetails.cs
+69
-0
69 additions, 0 deletions
ATxCommon/DirectoryDetails.cs
with
70 additions
and
0 deletions
ATxCommon/ATxCommon.csproj
+
1
−
0
View file @
562efc7d
...
...
@@ -46,6 +46,7 @@
<Compile
Include=
"ActiveDirectory.cs"
/>
<Compile
Include=
"BuildDetails.cs"
/>
<Compile
Include=
"Conv.cs"
/>
<Compile
Include=
"DirectoryDetails.cs"
/>
<Compile
Include=
"FsUtils.cs"
/>
<Compile
Include=
"Monitoring\Cpu.cs"
/>
<Compile
Include=
"Monitoring\MonitorBase.cs"
/>
...
...
This diff is collapsed.
Click to expand it.
ATxCommon/DirectoryDetails.cs
0 → 100644
+
69
−
0
View file @
562efc7d
using
System
;
using
System.IO
;
using
NLog
;
namespace
ATxCommon
{
public
class
DirectoryDetails
{
private
static
readonly
Logger
Log
=
LogManager
.
GetCurrentClassLogger
();
private
long
_size
=
-
1
;
private
int
_age
=
-
1
;
/// <summary>
/// Initialize the DirectoryDetails object from the given DirectoryInfo.
/// </summary>
/// <param name="dirInfo">The DirectoryInfo object of the directory to investigate.</param>
public
DirectoryDetails
(
DirectoryInfo
dirInfo
)
{
Dir
=
dirInfo
;
}
/// <summary>
/// The underlying DirectoryInfo object.
/// </summary>
public
DirectoryInfo
Dir
{
get
;
}
/// <summary>
/// The age defined by the directory's NAME in days.
/// </summary>
public
int
AgeFromName
{
get
{
if
(
_age
<
0
)
_age
=
FsUtils
.
DirNameToAge
(
Dir
,
DateTime
.
Now
);
return
_age
;
}
}
/// <summary>
/// The full size of the directory tree in bytes.
/// </summary>
public
long
Size
{
get
{
if
(
_size
>=
0
)
return
_size
;
try
{
_size
=
FsUtils
.
GetDirectorySize
(
Dir
.
FullName
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"ERROR getting directory size of [{0}]: {1}"
,
Dir
.
FullName
,
ex
.
Message
);
}
return
_size
;
}
}
/// <summary>
/// Human friendly description of the directory's age, derived from its NAME.
/// </summary>
public
string
HumanAgeFromName
=>
TimeUtils
.
DaysToHuman
(
AgeFromName
,
false
);
/// <summary>
/// Human friendly description of the directory tree size (recursively).
/// </summary>
public
string
HumanSize
=>
Conv
.
BytesToString
(
Size
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment