summaryrefslogtreecommitdiffstats
path: root/private/nw/convert/nwconv/filesel.h
blob: f09ac16767297d581e4e4578699c15e7330569a7 (plain) (blame)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*+-------------------------------------------------------------------------+
  | Copyright 1993-1994 (C) Microsoft Corporation - All rights reserved.    |
  +-------------------------------------------------------------------------+*/

#ifndef _HFILESEL_
#define _HFILESEL_

#ifdef __cplusplus
extern "C"{
#endif

// Forward references as the structures are recursively linked
struct _DIR_BUFFER;
struct _DIR_LIST;
struct _FILE_BUFFER;
struct _FILE_LIST;
struct SHARE_BUFFER;

/*+-------------------------------------------------------------------------+
  |
  |  The dir/file lists contain all the information used when working with
  |  a file tree.  The naming convention is that a buffer (I.E.
  |  DIR_BUFFER) contains the information for one entry (one directory
  |  or one file).  A List is an array of buffers of the appropriate
  |  type (DIR_LIST contains an array of DIR_BUFFERS).
  |
  |  The whole mess starts with a root DIR_BUFFER, the DIR_BUFFER then 
  |  points to a cascading chain of DIR and FILE LISTS.
  |
  |  Almost all of the structures are a doubly linked list with a pointer back
  |  to their parent.  A buffer parent pointer, points to it's parent list
  |  structure.  The List structure then has a back pointer to the parent
  |  DIR_BUFFER.  This facilitates recursing up and down the chain when
  |  an item is checked/un-checked and it's parent and/or children are affected.
  |  
  |  +--------+     +----------+
  |  |  Dir   |<--->| Dir List |
  |  | Buffer |<-+  +----------+
  |  +--------+  |  |   Dir    |-->Dir List...
  |              |  |  Buffer  |-->File List...
  |              |  + - - - - -+
  |              |  |          |
  |              |  + - - - - -+
  |              |  |          |
  |              |
  |              |
  |              |  +-----------+
  |              +->| File List |
  |                 +-----------+
  |                 |   File    |
  |                 |  Buffer   |
  |                 + - - - - - +
  |                 |           |
  |                 + - - - - - +
  |                 |           |
  |
  +-------------------------------------------------------------------------+*/
#define CONVERT_NONE 0
#define CONVERT_ALL 1
#define CONVERT_PARTIAL 2
  
// A dir buffer holds a directory or sub-directory entry, with pointers to the
// files and other dirs within it.
typedef struct _DIR_BUFFER {
   TCHAR Name[MAX_PATH];
   struct _DIR_LIST *parent;
   BOOL Last;                    // Flag is last dir-buffer in list
   DWORD Attributes;
   BYTE Convert;                 // None, All or Partial
   BOOL Special;

   struct _DIR_LIST *DirList;    // Directory List structure
   struct _FILE_LIST *FileList;  // File List structure
} DIR_BUFFER;

// A dir list contains the sub-directories in a directory - basically a count
// and then array of sub-dirs.
typedef struct _DIR_LIST {
   ULONG Count;
   DIR_BUFFER *parent;
   UINT Level;             // how deeply nested in file tree (nesting level)
   DIR_BUFFER DirBuffer[];
} DIR_LIST;


// Structures to hold information on individual files selected/de-selected for
// conversion
typedef struct _FILE_BUFFER {
   TCHAR Name[MAX_PATH];
   struct _FILE_LIST *parent;
   BOOL Convert;
   DWORD Attributes;
   ULONG Size;
} FILE_BUFFER;

typedef struct _FILE_LIST {
   ULONG Count;
   DIR_BUFFER *parent;
   FILE_BUFFER FileBuffer[];
} FILE_LIST;


typedef struct _FILE_PATH_BUFFER {
   LPTSTR Server;
   LPTSTR Share;
   LPTSTR Path;
   TCHAR FullPath[MAX_PATH + 1];
} FILE_PATH_BUFFER;


/*+-------------------------------------------------------------------------+
  | Function Prototypes                                                     |
  +-------------------------------------------------------------------------+*/
void TreeDelete(DIR_BUFFER *Dir);
void TreePrune(DIR_BUFFER *Dir);
ULONG TreeCount(DIR_BUFFER *Dir);
DIR_BUFFER *TreeCopy(DIR_BUFFER *Dir);

FILE_PATH_BUFFER *FilePathInit();
void FilePathServerSet(FILE_PATH_BUFFER *fpBuf, LPTSTR Server);
void FilePathShareSet(FILE_PATH_BUFFER *fpBuf, LPTSTR Share);
void FilePathPathSet(FILE_PATH_BUFFER *fpBuf, LPTSTR Path);

#ifdef __cplusplus
}
#endif

#endif