Blame src/GetFileInfo.h

Packit 8f70b4
/*
Packit 8f70b4
 * lftp - file transfer program
Packit 8f70b4
 *
Packit 8f70b4
 * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net)
Packit 8f70b4
 *
Packit 8f70b4
 * This program is free software; you can redistribute it and/or modify
Packit 8f70b4
 * it under the terms of the GNU General Public License as published by
Packit 8f70b4
 * the Free Software Foundation; either version 3 of the License, or
Packit 8f70b4
 * (at your option) any later version.
Packit 8f70b4
 *
Packit 8f70b4
 * This program is distributed in the hope that it will be useful,
Packit 8f70b4
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
 * GNU General Public License for more details.
Packit 8f70b4
 *
Packit 8f70b4
 * You should have received a copy of the GNU General Public License
Packit 8f70b4
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 8f70b4
 */
Packit 8f70b4
Packit 8f70b4
#ifndef GETFILEINFO_H
Packit 8f70b4
#define GETFILEINFO_H
Packit 8f70b4
Packit 8f70b4
#include "trio.h"
Packit 8f70b4
Packit 8f70b4
#include "SMTask.h"
Packit 8f70b4
#include "FileAccess.h"
Packit 8f70b4
Packit 8f70b4
class GetFileInfo : public ListInfo
Packit 8f70b4
{
Packit 8f70b4
   const FileAccessRef& session;
Packit 8f70b4
Packit 8f70b4
   SMTaskRef<ListInfo> li;
Packit 8f70b4
Packit 8f70b4
   /* file or dir we're listing: */
Packit 8f70b4
   xstring_c dir;
Packit 8f70b4
Packit 8f70b4
   /* directory we've actually listed: */
Packit 8f70b4
   xstring_c path_to_prefix;
Packit 8f70b4
Packit 8f70b4
   /* directory we started in: */
Packit 8f70b4
   FileAccess::Path origdir;
Packit 8f70b4
Packit 8f70b4
   /* In showdir mode, we make sure the path actually exists; this is
Packit 8f70b4
    * the filename to look for. */
Packit 8f70b4
   xstring verify_fn;
Packit 8f70b4
Packit 8f70b4
   bool showdir;
Packit 8f70b4
Packit 8f70b4
   enum state_t { INITIAL, CHANGE_DIR, CHANGING_DIR, GETTING_LIST, GETTING_INFO_ARRAY, DONE } state;
Packit 8f70b4
   /* whether we've tried to cd to the whole dir (treating it as a dir): */
Packit 8f70b4
   bool tried_dir;
Packit 8f70b4
   /* and whether we've tried to cd to the basename (treating it as a file): */
Packit 8f70b4
   bool tried_file;
Packit 8f70b4
   /* and the last-ditch GetInfoArray */
Packit 8f70b4
   bool tried_info;
Packit 8f70b4
   /* whether we found out the file type from cache */
Packit 8f70b4
   bool from_cache;
Packit 8f70b4
   /* whether the given path was a file or directory. */
Packit 8f70b4
   bool was_directory;
Packit 8f70b4
   /* if true, prepend the appropriate relative path to the result */
Packit 8f70b4
   bool prepend_path;
Packit 8f70b4
Packit 8f70b4
   xstring_c saved_error_text;
Packit 8f70b4
Packit 8f70b4
   FileSet get_info;
Packit 8f70b4
Packit 8f70b4
   void PrepareToDie();
Packit 8f70b4
Packit 8f70b4
public:
Packit 8f70b4
   GetFileInfo(const FileAccessRef& a, const char *path, bool showdir);
Packit 8f70b4
   virtual ~GetFileInfo();
Packit 8f70b4
Packit 8f70b4
   int Do();
Packit 8f70b4
   const char *Status();
Packit 8f70b4
   bool WasDirectory() const { return was_directory; }
Packit 8f70b4
   void DontPrependPath() { prepend_path=false; }
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
#endif /* GETFILEINFO_H */