|
Packit |
8f70b4 |
/*
|
|
Packit |
8f70b4 |
* lftp - file transfer program
|
|
Packit |
8f70b4 |
*
|
|
Packit |
8f70b4 |
* Copyright (c) 1996-2016 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 FILESETOUTPUT_H
|
|
Packit |
8f70b4 |
#define FILESETOUTPUT_H
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#include "FileSet.h"
|
|
Packit |
8f70b4 |
#include "buffer.h"
|
|
Packit |
8f70b4 |
#include "keyvalue.h"
|
|
Packit |
8f70b4 |
#include "FileCopy.h"
|
|
Packit |
8f70b4 |
#include "GetFileInfo.h"
|
|
Packit |
8f70b4 |
#include "CopyJob.h"
|
|
Packit |
8f70b4 |
#include "OutputJob.h"
|
|
Packit |
8f70b4 |
#include "Job.h"
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
class StatusLine;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
class FileSetOutput {
|
|
Packit |
8f70b4 |
const char *FileInfoSuffix(const FileInfo &fi) const;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
public:
|
|
Packit |
8f70b4 |
bool classify; // add / (dir) @ (link)
|
|
Packit |
8f70b4 |
// TODO: extra-optional * for exec? maybe not, some servers stick +x on everything
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
int width; // width to output, 0 to force one column
|
|
Packit |
8f70b4 |
bool color;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
enum { NONE=0, PERMS = 0x1, SIZE = 0x2, DATE = 0x4, LINKS = 0x8,
|
|
Packit |
8f70b4 |
USER = 0x10, GROUP = 0x20, NLINKS = 0x40,
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
ALL=PERMS|SIZE|DATE|LINKS|USER|GROUP|NLINKS
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
int mode;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
xstring_c pat;
|
|
Packit |
8f70b4 |
xstring_c time_fmt;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
bool basenames;
|
|
Packit |
8f70b4 |
bool showdots;
|
|
Packit |
8f70b4 |
bool quiet;
|
|
Packit |
8f70b4 |
bool patterns_casefold;
|
|
Packit |
8f70b4 |
bool sort_casefold;
|
|
Packit |
8f70b4 |
bool sort_reverse;
|
|
Packit |
8f70b4 |
bool sort_dirs_first;
|
|
Packit |
8f70b4 |
bool size_filesonly;
|
|
Packit |
8f70b4 |
bool single_column;
|
|
Packit |
8f70b4 |
bool list_directories;
|
|
Packit |
8f70b4 |
bool need_exact_time;
|
|
Packit |
8f70b4 |
int output_block_size;
|
|
Packit |
8f70b4 |
int human_opts;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
FileSet::sort_e sort;
|
|
Packit |
8f70b4 |
FileSetOutput(): classify(0), width(0), color(false), mode(NONE),
|
|
Packit |
8f70b4 |
basenames(false), showdots(false),
|
|
Packit |
8f70b4 |
quiet(false), patterns_casefold(false), sort_casefold(false), sort_reverse(false),
|
|
Packit |
8f70b4 |
sort_dirs_first(false), size_filesonly(false), single_column(false),
|
|
Packit |
8f70b4 |
list_directories(false), need_exact_time(false), output_block_size(0),
|
|
Packit |
8f70b4 |
human_opts(0), sort(FileSet::BYNAME) { }
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void long_list();
|
|
Packit |
8f70b4 |
void config(const OutputJob *fd);
|
|
Packit |
8f70b4 |
const char *parse_argv(const Ref<ArgV>& a);
|
|
Packit |
8f70b4 |
const char *parse_res(const char *res);
|
|
Packit |
8f70b4 |
static const char *ValidateArgv(xstring_c *s);
|
|
Packit |
8f70b4 |
int Need() const;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void print(FileSet &fs, const JobRef<OutputJob>& o) const;
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* Job interface to FileSetOutput */
|
|
Packit |
8f70b4 |
class clsJob : public SessionJob
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
JobRef<OutputJob> output;
|
|
Packit |
8f70b4 |
Ref<FileSetOutput> fso;
|
|
Packit |
8f70b4 |
Ref<ArgV> args;
|
|
Packit |
8f70b4 |
SMTaskRef<ListInfo> list_info;
|
|
Packit |
8f70b4 |
xstring_c dir;
|
|
Packit |
8f70b4 |
xstring_c mask;
|
|
Packit |
8f70b4 |
bool done;
|
|
Packit |
8f70b4 |
bool use_cache;
|
|
Packit |
8f70b4 |
bool error;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
enum { INIT, START_LISTING, GETTING_LIST_INFO, DONE } state;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
public:
|
|
Packit |
8f70b4 |
clsJob(FA *s, ArgV *a, FileSetOutput *_opts, OutputJob *output);
|
|
Packit |
8f70b4 |
int Done();
|
|
Packit |
8f70b4 |
int Do();
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void UseCache(bool y=true) { use_cache=y; }
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void Fg() { session->SetPriority(1); output->Fg(); }
|
|
Packit |
8f70b4 |
void Bg() { session->SetPriority(0); output->Bg(); }
|
|
Packit |
8f70b4 |
void SuspendInternal();
|
|
Packit |
8f70b4 |
void ResumeInternal();
|
|
Packit |
8f70b4 |
int ExitCode() { return error||output->Error() ? 1 : 0; }
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void ShowRunStatus(const SMTaskRef<StatusLine>&);
|
|
Packit |
8f70b4 |
xstring& FormatStatus(xstring&,int v,const char *);
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#endif
|