~ubuntu-branches/ubuntu/precise/fte/precise

« back to all changes in this revision

Viewing changes to src/o_directory.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Neil Williams
  • Date: 2011-08-14 10:28:46 UTC
  • mfrom: (1.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110814102846-kate2jfkduwpnika
Tags: 0.50.2b6-1
* QA upload.
* Synchronise with current upstream sources.
  (Closes: #195945)
* Include NMUs by Nobuhiro Iwamatsu and Hideki Yamane,
  thanks to both.
* Move to 3.0 quilt

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 *
8
8
 */
9
9
 
 
10
#include <stdio.h>
 
11
#include <time.h>
 
12
 
10
13
#include "o_directory.h"
11
14
 
 
15
#include "c_config.h"
12
16
#include "c_commands.h"
13
17
#include "c_history.h"
14
18
#include "i_modelview.h"
54
58
        struct tm *t;
55
59
        time_t tim;
56
60
        off_t Size = Files[Line]->Size();
57
 
        char SizeStr[16];
 
61
        char SizeStr[16];
 
62
        char ModeStr[11];
58
63
 
59
64
        tim = Files[Line]->MTime();
60
65
        t = localtime(&tim);
79
84
        } else
80
85
            sprintf(SizeStr, "%8ld", (long) Size);
81
86
 
 
87
#ifdef UNIX
 
88
        if (Files[Line]->Mode() >= 0)
 
89
        {
 
90
            const int mode = Files[Line]->Mode();
 
91
            ModeStr[0] = mode & S_IFDIR ? 'd' : '-';
 
92
            ModeStr[1] = mode & S_IRUSR ? 'r' : '-';
 
93
            ModeStr[2] = mode & S_IWUSR ? 'w' : '-';
 
94
            ModeStr[3] = mode & S_IXUSR ? 'x' : '-';
 
95
            ModeStr[4] = mode & S_IRGRP ? 'r' : '-';
 
96
            ModeStr[5] = mode & S_IWGRP ? 'w' : '-';
 
97
            ModeStr[6] = mode & S_IXGRP ? 'x' : '-';
 
98
            ModeStr[7] = mode & S_IROTH ? 'r' : '-';
 
99
            ModeStr[8] = mode & S_IWOTH ? 'w' : '-';
 
100
            ModeStr[9] = mode & S_IXOTH ? 'x' : '-';
 
101
            ModeStr[10] = '\0';
 
102
        }
 
103
        else
 
104
            ModeStr[0] = '\0';
 
105
#endif
 
106
 
82
107
        int l = snprintf(s, sizeof(s),
 
108
#ifdef UNIX
 
109
                         "%10s "
 
110
#endif
83
111
                         "%04d/%02d/%02d %02d:%02d:%02d %s %s%c",
 
112
#ifdef UNIX
 
113
                         ModeStr,
 
114
#endif
84
115
                         Year, Mon, Day, Hour, Min, Sec, SizeStr,
85
116
                         Files[Line]->Name(),
86
117
                         (Files[Line]->Type() == fiDIRECTORY) ? SLASH : ' ');
131
162
 
132
163
    rc = ff->FindFirst(&fi);
133
164
    while (rc == 0) {
134
 
        assert(fi != 0);
135
 
        if (strcmp(fi->Name(), ".") != 0) {
 
165
        assert(fi != 0);
 
166
 
 
167
        if (
 
168
            strcmp(fi->Name(), ".") != 0 &&
 
169
            ( ShowTildeFilesInDirList || fi->Name()[strlen(fi->Name())-1] != '~' )
 
170
           ) {
136
171
            Files = (FileInfo **)realloc((void *)Files, ((FCount | 255) + 1) * sizeof(FileInfo *));
137
172
            if (Files == 0)
138
173
            {
192
227
    case ExActivateInOtherWindow:
193
228
        SearchLen = 0;
194
229
        Msg(S_INFO, "");
195
 
        if (Files && Row >= 0 && Row < FCount) {
196
 
            if (isDir(Row)) {
197
 
            } else {
 
230
        if (Files && Row >= 0 && Row < FCount)
 
231
            if (!isDir(Row))
198
232
                return FmLoad(Files[Row]->Name(), View->Next);
199
 
            }
200
 
        }
201
 
        return ErFAIL;
 
233
        return 0;
202
234
 
203
235
    case ExRescan:
204
 
        if (RescanDir() == 0)
205
 
            return ErFAIL;
206
 
        return ErOK;
 
236
        return RescanDir();
207
237
 
208
238
    case ExDirGoUp:
209
239
        SearchLen = 0;
210
240
        Msg(S_INFO, "");
211
241
        FmChDir(SDOT SDOT);
212
 
        return ErOK;
 
242
        return 1;
213
243
 
214
244
    case ExDirGoDown:
215
245
        SearchLen = 0;
217
247
        if (Files && Row >= 0 && Row < FCount) {
218
248
            if (isDir(Row)) {
219
249
                FmChDir(Files[Row]->Name());
220
 
                return ErOK;
 
250
                return 1;
221
251
            }
222
252
        }
223
 
        return ErFAIL;
 
253
        return 0;
224
254
 
225
255
    case ExDirGoto:
226
256
        SearchLen = 0;
231
261
        SearchLen = 0;
232
262
        Msg(S_INFO, "");
233
263
        FmChDir(SSLASH);
234
 
        return ErOK;
 
264
        return 1;
235
265
 
236
266
    case ExDirSearchCancel:
237
267
        // Kill search when moving
238
268
        SearchLen = 0;
239
269
        Msg(S_INFO, "");
240
 
        return ErOK;
 
270
        return 1;
241
271
 
242
272
    case ExDirSearchNext:
243
273
        // Find next matching file, search is case in-sensitive while sorting is sensitive
249
279
                }
250
280
            }
251
281
        }
252
 
        return ErOK;
 
282
        return 1;
253
283
 
254
284
    case ExDirSearchPrev:
255
285
        // Find prev matching file, search is case in-sensitive while sorting is sensitive
261
291
                }
262
292
            }
263
293
        }
264
 
        return ErOK;
 
294
        return 1;
265
295
 
266
296
    case ExDeleteFile:
267
297
        SearchLen = 0;