~ubuntu-branches/ubuntu/trusty/vice/trusty

« back to all changes in this revision

Viewing changes to src/fsdevice/fsdevice-read.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2013-07-28 20:38:23 UTC
  • mfrom: (1.2.5)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: package-import@ubuntu.com-20130728203823-w495rps5wuykespp
Tags: upstream-2.4.dfsg
ImportĀ upstreamĀ versionĀ 2.4.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
166
166
 
167
167
    bufinfo->bufp = bufinfo->name;
168
168
 
169
 
    if (fsdevice_convert_p00_enabled[(vdrive->unit) - 8])
 
169
    if (fsdevice_convert_p00_enabled[(vdrive->unit) - 8]) {
170
170
        format |= FILEIO_FORMAT_P00;
171
 
    if (!fsdevice_hide_cbm_files_enabled[vdrive->unit - 8])
 
171
    }
 
172
    if (!fsdevice_hide_cbm_files_enabled[vdrive->unit - 8]) {
172
173
        format |= FILEIO_FORMAT_RAW;
 
174
    }
173
175
 
174
176
    /*
175
177
     * Find the next directory entry and return it as a CBM
181
183
    f = 1;
182
184
    do {
183
185
        BYTE *p;
184
 
        finfo = NULL; /* iAN CooG 31/08 */
 
186
        finfo = NULL;
185
187
 
186
188
        direntry = ioutil_readdir(bufinfo->ioutil_dir);
187
189
 
188
 
        if (direntry == NULL)
 
190
        if (direntry == NULL) {
189
191
            break;
 
192
        }
190
193
 
191
194
        finfo = fileio_open(direntry, bufinfo->dir, format,
192
 
                            FILEIO_COMMAND_READ | FILEIO_COMMAND_FSNAME,
 
195
                            FILEIO_COMMAND_STAT | FILEIO_COMMAND_FSNAME,
193
196
                            FILEIO_TYPE_PRG);
194
197
 
195
 
        if (finfo == NULL)
 
198
        if (finfo == NULL) {
196
199
            continue;
 
200
        }
197
201
 
198
202
        bufinfo->type = finfo->type;
199
203
 
200
 
        if (bufinfo->dirmask[0] == '\0')
 
204
        if (bufinfo->dirmask[0] == '\0') {
201
205
            break;
 
206
        }
202
207
 
203
208
        l = (int)strlen(bufinfo->dirmask);
204
209
 
211
216
                    f = 0;
212
217
                    break;
213
218
                } /* end mask */
214
 
                while (*p && (*p != bufinfo->dirmask[i + 1]))
 
219
                while (*p && (*p != bufinfo->dirmask[i + 1])) {
215
220
                    p++;
 
221
                }
216
222
            } else {
217
 
                if (*p != bufinfo->dirmask[i])
 
223
                if (*p != bufinfo->dirmask[i]) {
218
224
                    break;
 
225
                }
219
226
                p++;
220
227
            }
221
228
            if ((!*p) && (!(bufinfo->dirmask[i + 1]))) {
223
230
                break;
224
231
            }
225
232
        }
226
 
        if (f > 0)
 
233
        if (f > 0) {
227
234
            fileio_close(finfo);
 
235
        }
228
236
    } while (f);
229
237
 
230
238
    if (direntry != NULL) {
240
248
        *p++ = 1;
241
249
 
242
250
        statrc = ioutil_stat(buf, &filelen, &isdir);
243
 
        if (statrc == 0)
 
251
        if (statrc == 0) {
244
252
            blocks = (filelen + 253) / 254;
245
 
        else
 
253
        } else {
246
254
            blocks = 0;   /* this file can't be opened */
 
255
        }
247
256
 
248
 
        if (blocks > 0xffff)
 
257
        if (blocks > 0xffff) {
249
258
            blocks = 0xffff; /* Limit file size to 16 bits.  */
 
259
        }
250
260
 
251
261
        SET_LO_HI(p, blocks);
252
262
 
253
 
        if (blocks < 10)
254
 
            *p++ = ' ';
255
 
        if (blocks < 100)
256
 
            *p++ = ' ';
257
 
        if (blocks < 1000)
258
 
            *p++ = ' ';
 
263
        if (blocks < 10) {
 
264
            *p++ = ' ';
 
265
        }
 
266
        if (blocks < 100) {
 
267
            *p++ = ' ';
 
268
        }
 
269
        if (blocks < 1000) {
 
270
            *p++ = ' ';
 
271
        }
259
272
 
260
273
        /*
261
274
         * Filename
263
276
 
264
277
        *p++ = '"';
265
278
 
266
 
        for (i = 0; finfo->name[i] && (*p = finfo->name[i]); ++i, ++p);
 
279
        for (i = 0; finfo->name[i] && (*p = finfo->name[i]); ++i, ++p) {
 
280
            ;
 
281
        }
267
282
 
268
283
        *p++ = '"';
269
 
        for (; i < 16; i++)
 
284
        for (; i < 16; i++) {
270
285
            *p++ = ' ';
 
286
        }
271
287
 
272
288
        if (isdir != 0) {
273
289
            *p++ = ' '; /* normal file */
275
291
            *p++ = 'I';
276
292
            *p++ = 'R';
277
293
        } else {
278
 
            if (blocks)
 
294
            if (blocks) {
279
295
                *p++ = ' '; /* normal file */
280
 
            else
 
296
            } else {
281
297
                *p++ = '*'; /* splat file */
 
298
            }
282
299
            switch(bufinfo->type) {
283
300
              case CBMDOS_FT_DEL:
284
301
                *p++ = 'D';
308
325
            }
309
326
        }
310
327
 
311
 
        if (ioutil_access(buf, IOUTIL_ACCESS_W_OK))
 
328
        if (ioutil_access(buf, IOUTIL_ACCESS_W_OK)) {
312
329
            *p++ = '<'; /* read-only file */
 
330
        }
313
331
 
314
332
        *p = '\0';        /* to allow strlen */
315
333
 
344
362
        bufinfo->eof++;
345
363
    }
346
364
 
347
 
    if (finfo != NULL) /* iAN CooG 31/08 */
 
365
    if (finfo != NULL) {
348
366
        fileio_close(finfo);
 
367
    }
349
368
 
350
369
    lib_free(buf);
351
370
}