Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
LocalDisk.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.coreutils;
20 
24 public class LocalDisk {
25 
26  private String name;
27  private String path;
28  private long size;
29 
30  public LocalDisk(String name, String path, long size) {
31  this.name = name;
32  this.path = path;
33  this.size = size;
34  }
35 
36  public String getName() {
37  return name;
38  }
39 
40  public String getPath() {
41  return path;
42  }
43 
44  public long getSize() {
45  return size;
46  }
47 
48  public String getReadableSize() {
49  int unit = 1024;
50  if (size < unit) {
51  return size + " B"; //NON-NLS
52  }
53  int exp = (int) (Math.log(size) / Math.log(unit));
54  String pre = "KMGTPE".charAt(exp - 1) + ""; //NON-NLS
55  return String.format("%.1f %sB", size / Math.pow(unit, exp), pre); //NON-NLS
56  }
57 
58  @Override
59  public String toString() {
60  return name + ": " + getReadableSize();
61  }
62 
63 }
LocalDisk(String name, String path, long size)
Definition: LocalDisk.java:30

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.