Autopsy  3.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  private String name;
26  private String path;
27  private long size;
28 
29  public LocalDisk(String name, String path, long size) {
30  this.name = name;
31  this.path = path;
32  this.size = size;
33  }
34 
35  public String getName() {
36  return name;
37  }
38 
39  public String getPath() {
40  return path;
41  }
42 
43  public long getSize() {
44  return size;
45  }
46 
47  public String getReadableSize() {
48  int unit = 1024;
49  if (size < unit) {
50  return size + " B"; //NON-NLS
51  }
52  int exp = (int) (Math.log(size) / Math.log(unit));
53  String pre = "KMGTPE".charAt(exp-1) + ""; //NON-NLS
54  return String.format("%.1f %sB", size / Math.pow(unit, exp), pre); //NON-NLS
55  }
56 
57  @Override
58  public String toString() {
59  return name + ": " + getReadableSize();
60  }
61 
62 }
LocalDisk(String name, String path, long size)
Definition: LocalDisk.java:29

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