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.remotefile;
19:
20: import java.io.Serializable;
21:
22: /**
23: * @author zubov
24: * @version $Id: LightRemoteFile.java 925 2005-01-25 22:08:07Z zubov $
25: * For use in sending the filelist from the slave to the master
26: */
27: public final class LightRemoteFile extends AbstractLightRemoteFile
28: implements Serializable {
29: private String _filename;
30: private long _lastModified;
31: private long _length;
32:
33: private boolean _isFile;
34: private boolean _isDirectory;
35:
36: private void setName(String name) {
37: if (name.indexOf("\\") != -1) {
38: throw new RuntimeException(
39: "\\ is not an allowed character in filenames");
40: }
41: _filename = name;
42: }
43:
44: public LightRemoteFile(LightRemoteFileInterface file) {
45: setName(file.getName());
46: _lastModified = file.lastModified();
47: _length = file.length();
48: _isFile = file.isFile();
49: _isDirectory = file.isDirectory();
50: }
51:
52: /**
53: * Will create a directory
54: */
55: public LightRemoteFile(String filename, long lastModified) {
56: setName(filename);
57: _lastModified = lastModified;
58: _length = 0;
59: _isDirectory = true;
60: }
61:
62: /**
63: * Will create a file
64: */
65: public LightRemoteFile(String filename, long lastModified,
66: long length) {
67: setName(filename);
68: _lastModified = lastModified;
69: _length = length;
70: _isDirectory = false;
71: }
72:
73: public boolean isDirectory() {
74: return _isDirectory;
75: }
76:
77: public boolean isFile() {
78: return !_isDirectory;
79: }
80:
81: public long lastModified() {
82: return _lastModified;
83: }
84:
85: public long length() {
86: return _length;
87: }
88:
89: public String getName() {
90: return _filename;
91: }
92: }
|