File: ClientFileBrowser.h

package info (click to toggle)
postman 2.0-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,036 kB
  • ctags: 3,078
  • sloc: cpp: 31,131; ansic: 1,948; sh: 787; makefile: 285
file content (111 lines) | stat: -rw-r--r-- 3,867 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
ClientFileBrowser.h
*/

#ifndef __CLIENTFILEBROWSER_H
#define __CLIENTFILEBROWSER_H

#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <signal.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <values.h>
       
#include "Language.h"
#include "Utils.h"
#include "Config.h"
#include "XSocket.h"
#include "XVector.h"

#define NEWDIRSMODE  0770

typedef struct 
  {
  TFileName FileName;
  xulong size;
  time_t st_mtime;
  int type; //DIR, NORMAL FILE, etc.
  bool Cortado, Copiado; 
  } XFile, *PXFile;    
typedef XVector<XFile> FileList;

typedef struct 
  {
  TBuffer DiskName, Label, mount_dir, umount_cmd, restricted_dir, mount_cmd;
  bool mounted;
  long quota, diskusage;
  } XDisk, *PXDisk;    
typedef XVector<XDisk> DiskList;

void CFB_FlipEntries (const void *e1, const void *e2);
int CFB_CompareEntriesByFileName  (const void *e1, const void *e2);
int CFB_CompareEntriesByFileNameCS (const void *e1, const void *e2);
int CFB_CompareEntriesByFileSize  (const void *e1, const void *e2);
int CFB_CompareEntriesByFileDate  (const void *e1, const void *e2);

class ClientFileBrowser
  {
  private:
    TBuffer RestrictedPath, CurrentFullDir, CurrentRelDir, ErrorMsg;
    long DiskUsage, QUOTA;
    int CurrentDisk;
    const char *getExtension (const char *afile, TBuffer extension);
    bool isFullDirectory (const char *adirname);
  public:
    FileList FLAllFiles;                   
    ClientFileBrowser (int aCurrentDisk, const char *aRestrictedPath, long aDiskUsage, long aQUOTA);
    virtual ~ClientFileBrowser ();
    void init (int aCurrentDisk, const char *aRestrictedPath, long aDiskUsage, long aQUOTA);
    bool isCorrectFullDir (const char *apath);
    const char *getCurrentFullDir (void);
    const char *getCurrentRelDir (void);
    const char *getErrorMsg (void);
    char *escape_input (const char *source, TBuffer dest);
    char *unescape_input (const char *source, TBuffer dest);    
    const char *obtainOldCurrentRelDir (void);    
    const char *obtainRelDir (const char *FullDir, TBuffer reldir);
    bool obtainFullName (const char *afile, TBuffer fullfilename);    
    bool isEditableFile (const char *afile);
    int getCurrentDisk (void);
    void setCurrentDisk (int aCurrentDisk);
    bool setCurrentRelDir (const char *aCurrentRelDir);    
    bool obtainFileList (void);

    bool changeAbsDir (const char *newdir);
    bool changeRelDir (const char *newdir);
    bool CwdUp (void);
    bool CwdNonRelative (const char *anewdir);
    bool Cwd (const char *newdir);
    const char *getFileDate (time_t *tt, TBuffer abuf);
    const char *getFilenameFromFullFilename (const char *fullname, TBuffer filename);          
    bool dumpFile (const char *afile, char *fullfilename, char *CT);
    bool saveFile (const char *afilename, const char *filetext);
    bool makeDir (const char *adirname);
    bool makeFile (const char *afilename);
    bool deleteItems (StringList *SLMulti, int *itemsdeleted);
    bool rmFullDir (const char *adirname, int *itemsdeleted);
    bool listFullDir (const char *adirname, StringList *SLFileList);
    bool cpFullDir (const char *src_dirname, const char *dest_dirname);
    bool isDirectory (const char *adirname);
    bool pasteItems (StringList *SLPapeleraCopy, StringList *SLPapeleraCut);
    const char *FormatCountBytes (long count, TBuffer abuf);    
    void parseIncrementalPath (const char *adir, StringList *SL, StringList *SLInc);
    bool renameItems (const char *oldfilename, const char *newfilename);
    bool sortName (void);       
    bool sortDate (void);
    bool sortSize (void);
    long getDiskUsage (void);
    void addDiskUsage (long morebytes);
    void delDiskUsage (long lessbytes);
    float getPercQuotaUsage (void);
    long getQuota (void);
  };

#endif