View Javadoc

1   /**
2    * This file is part of Waarp Project.
3    * 
4    * Copyright 2009, Frederic Bregier, and individual contributors by the @author tags. See the
5    * COPYRIGHT.txt in the distribution for a full listing of individual contributors.
6    * 
7    * All Waarp Project is free software: you can redistribute it and/or modify it under the terms of
8    * the GNU General Public License as published by the Free Software Foundation, either version 3 of
9    * the License, or (at your option) any later version.
10   * 
11   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
12   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13   * Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License along with Waarp . If not, see
16   * <http://www.gnu.org/licenses/>.
17   */
18  package org.waarp.ftp.simpleimpl.file;
19  
20  import java.io.File;
21  
22  import org.waarp.common.command.exception.CommandAbstractException;
23  import org.waarp.ftp.core.file.FtpFile;
24  import org.waarp.ftp.core.session.FtpSession;
25  import org.waarp.ftp.filesystembased.FilesystemBasedFtpFile;
26  
27  /**
28   * FtpFile implementation based on true directories and files
29   * 
30   * @author Frederic Bregier
31   * 
32   */
33  public class FileBasedFile extends FilesystemBasedFtpFile {
34      /**
35       * @param session
36       * @param fileBasedDir
37       *            It is not necessary the directory that owns this file.
38       * @param path
39       * @param append
40       * @throws CommandAbstractException
41       */
42      public FileBasedFile(FtpSession session, FileBasedDir fileBasedDir,
43              String path, boolean append) throws CommandAbstractException {
44          super(session, fileBasedDir, path, append);
45      }
46  
47      /**
48       * This method is a good to have in a true {@link FtpFile} implementation.
49       * 
50       * @return the File associated with the current FtpFile operation
51       */
52      public File getTrueFile() {
53          try {
54              return getFileFromPath(getFile());
55          } catch (CommandAbstractException e) {
56              return null;
57          }
58      }
59  }