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