|
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 |
#ifndef FINDJOBDU_H
|
|
Packit |
8f70b4 |
#define FINDJOBDU_H
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#include "FindJob.h"
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
class FinderJob_Du : public FinderJob
|
|
Packit |
8f70b4 |
{
|
|
Packit |
8f70b4 |
SMTaskRef<IOBuffer> buf;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
/* We keep traversing deeper than this, but we never print a total
|
|
Packit |
8f70b4 |
* past this. */
|
|
Packit |
8f70b4 |
int max_print_depth;
|
|
Packit |
8f70b4 |
bool print_totals;
|
|
Packit |
8f70b4 |
int output_block_size;
|
|
Packit |
8f70b4 |
int human_opts;
|
|
Packit |
8f70b4 |
bool all_files;
|
|
Packit |
8f70b4 |
bool separate_dirs;
|
|
Packit |
8f70b4 |
bool file_count;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
bool success;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
long long tot_size;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void Init(const char *d);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
struct stack_entry {
|
|
Packit |
8f70b4 |
xstring_c dir;
|
|
Packit |
8f70b4 |
long long size;
|
|
Packit |
8f70b4 |
stack_entry(const char *dir) : dir(dir), size(0) {}
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
RefArray<stack_entry> size_stack;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
Ref<ArgV> args;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void print_size (long long n_blocks, const char *string);
|
|
Packit |
8f70b4 |
off_t BlockCeil(off_t size) const;
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
// prepends last directory name
|
|
Packit |
8f70b4 |
const char *MakeFileName(const char *n);
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void Push (const char *d);
|
|
Packit |
8f70b4 |
void Pop();
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
public:
|
|
Packit |
8f70b4 |
FinderJob_Du(FileAccess *s,ArgV *a,FDStream *o);
|
|
Packit |
8f70b4 |
~FinderJob_Du();
|
|
Packit |
8f70b4 |
int Done();
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
void PrintTotals() { print_totals=true; }
|
|
Packit |
8f70b4 |
void SetBlockSize(int n,int ho) { output_block_size = n; human_opts = ho; }
|
|
Packit |
8f70b4 |
void PrintDepth(int n) { max_print_depth = n; }
|
|
Packit |
8f70b4 |
void AllFiles() { all_files=true; }
|
|
Packit |
8f70b4 |
void SeparateDirs() { separate_dirs=true; }
|
|
Packit |
8f70b4 |
void FileCount() { file_count=true; }
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
protected:
|
|
Packit |
8f70b4 |
/* virtuals */
|
|
Packit |
8f70b4 |
prf_res ProcessFile(const char *d,const FileInfo *fi);
|
|
Packit |
8f70b4 |
void ProcessList(FileSet *f);
|
|
Packit |
8f70b4 |
void Finish();
|
|
Packit |
8f70b4 |
void Enter(const char *d);
|
|
Packit |
8f70b4 |
void Exit();
|
|
Packit |
8f70b4 |
};
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
#endif // FINDJOBDU_H
|