01: /*
02: * This file is part of DrFTPD, Distributed FTP Daemon.
03: *
04: * DrFTPD is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * DrFTPD is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with DrFTPD; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18: package org.drftpd.slave;
19:
20: import se.mog.io.File;
21:
22: import java.io.IOException;
23:
24: /**
25: * @author mog
26: * @version $Id: Root.java 781 2004-11-09 19:00:01Z mog $
27: */
28: public class Root {
29: private File _rootFile;
30: private String _root;
31: private long _minSpaceFree = 50000000; //50,000,000 = 50mb
32: private int _priority = 0;
33: private long _lastModified;
34:
35: public Root(String root) throws IOException {
36: _rootFile = new File(new File(root).getCanonicalFile());
37: _root = _rootFile.getPath();
38: _lastModified = getFile().lastModified();
39: }
40:
41: public File getFile() {
42: return _rootFile;
43: }
44:
45: public String getPath() {
46: return _root;
47: }
48:
49: public long lastModified() {
50: return _lastModified;
51: }
52:
53: public void touch() {
54: getFile().setLastModified(
55: _lastModified = System.currentTimeMillis());
56: }
57:
58: public long getMinSpaceFree() {
59: return _minSpaceFree;
60: }
61:
62: public int getPriority() {
63: return _priority;
64: }
65:
66: public String toString() {
67: return "[root=" + getPath() + "]";
68: }
69:
70: public long getDiskSpaceAvailable() {
71: return getFile().getDiskSpaceAvailable();
72: }
73:
74: public long getDiskSpaceCapacity() {
75: return getFile().getDiskSpaceCapacity();
76: }
77:
78: public File getFile(String path) {
79: return new File(_root + File.separator + path);
80: }
81:
82: /**
83: * Returns true if File.getDiskSpaceAvailable() is less than getMinSpaceFree()
84: * @return true if File.getDiskSpaceAvailable() is less than getMinSpaceFree()
85: */
86: public boolean isFull() {
87: return getFile().getDiskSpaceAvailable() < getMinSpaceFree();
88: }
89: }
|