KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > drftpd > slave > Root


1 /*
2  * This file is part of DrFTPD, Distributed FTP Daemon.
3  *
4  * DrFTPD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 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 net.sf.drftpd.slave;
19
20 import java.io.IOException JavaDoc;
21
22 import se.mog.io.File;
23
24 /**
25  * @author mog
26  * @version $Id: Root.java,v 1.8 2004/05/12 00:45:11 mog Exp $
27  */

28 public class Root {
29     private File _rootFile;
30     private String JavaDoc _root;
31     private long _minSpaceFree = 50000000; //50,000,000 = 50mb
32
private int _priority = 0;
33     private long _lastModified;
34
35     public Root(String JavaDoc root, long minSpaceFree, int priority) throws IOException JavaDoc {
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 JavaDoc getPath() {
46         return _root;
47     }
48
49     public long lastModified() {
50         return _lastModified;
51     }
52
53     public void touch() {
54         getFile().setLastModified(_lastModified = System.currentTimeMillis());
55     }
56
57     public long getMinSpaceFree() {
58         return _minSpaceFree;
59     }
60
61     public int getPriority() {
62         return _priority;
63     }
64
65     public String JavaDoc toString() {
66         return "[root=" + getPath() + "]";
67     }
68
69     public long getDiskSpaceAvailable() {
70         return getFile().getDiskSpaceAvailable();
71     }
72
73     public long getDiskSpaceCapacity() {
74         return getFile().getDiskSpaceCapacity();
75     }
76
77     public File getFile(String JavaDoc path) {
78         return new File(_root + File.separator + path);
79     }
80
81     /**
82      * Returns true if File.getDiskSpaceAvailable() is less than getMinSpaceFree()
83      * @return true if File.getDiskSpaceAvailable() is less than getMinSpaceFree()
84      */

85     public boolean isFull() {
86         return getFile().getDiskSpaceAvailable() < getMinSpaceFree();
87     }
88 }
89
Popular Tags