~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to routines/wsci/files.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * From TclWinFCmd.c
 
4
 *
 
5
 *      This file implements the Windows specific portion of file manipulation 
 
6
 *      subcommands of the "file" command. 
 
7
 *
 
8
 * Copyright (c) 1996-1997 Sun Microsystems, Inc.
 
9
 *
 
10
 * See the file "license.terms" for information on usage and redistribution
 
11
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
12
 *
 
13
 * SCCS: @(#) SciWinFCmd.c 1.19 97/08/05 15:23:47
 
14
 */
 
15
 
 
16
#include <windows.h>
 
17
#include "dstrings.h"
 
18
#include <errno.h>
 
19
#ifdef __ABSC__
 
20
#include "errno.h"
 
21
#endif
 
22
 
 
23
/*
 
24
 * The following constants specify the type of callback when
 
25
 * TraverseWinTree() calls the traverseProc()
 
26
 */
 
27
 
 
28
#define DOTREE_PRED   1         /* pre-order directory  */
 
29
#define DOTREE_POSTD  2         /* post-order directory */
 
30
#define DOTREE_F      3         /* regular file */
 
31
 
 
32
extern int SciWinGetPlatformId ();
 
33
extern void SciWinConvertError (DWORD errCode);
 
34
extern void sciprint (char *fmt,...);
 
35
/*
 
36
 * Prototype for the TraverseWinTree callback function.
 
37
 */
 
38
 
 
39
typedef int (TraversalProc) (char *src, char *dst, DWORD attr, int type,
 
40
                             Sci_DString * errorPtr);
 
41
 
 
42
/*
 
43
 * Declarations for local procedures defined in this file:
 
44
 */
 
45
 
 
46
 
 
47
static int TraversalDelete (char *src, char *dst, DWORD attr,
 
48
                            int type, Sci_DString * errorPtr);
 
49
static int TraverseWinTree (TraversalProc * traverseProc,
 
50
                            Sci_DString * sourcePtr, Sci_DString * destPtr,
 
51
                            Sci_DString * errorPtr);
 
52
 
 
53
static int ScipRemoveDirectory (
 
54
                                 char *path,    /* Pathname of directory to be removed. */
 
55
                                 int recursive,         /* If non-zero, removes directories that
 
56
                                                         * are nonempty.  Otherwise, will only remove
 
57
                                                         * empty directories. */
 
58
                                 Sci_DString * errorPtr);       /* If non-NULL, initialized DString for
 
59
                                                                 * error reporting. */
 
60
 
 
61
 
 
62
/*
 
63
 *---------------------------------------------------------------------------
 
64
 *
 
65
 * SciCreateDirectory --
 
66
 *
 
67
 *      Creates the specified directory.  All parent directories of the
 
68
 *      specified directory must already exist.  The directory is
 
69
 *      automatically created with permissions so that user can access
 
70
 *      the new directory and create new files or subdirectories in it.
 
71
 *
 
72
 * Results:
 
73
 *      If the directory was successfully created, returns SCI_OK.
 
74
 *      Otherwise the return value is SCI_ERROR and errno is set to
 
75
 *      indicate the error.  Some possible values for errno are:
 
76
 *
 
77
 *      EACCES:     a parent directory can't be read and/or written.
 
78
 *      EEXIST:     path already exists.
 
79
 *      ENOENT:     a parent directory doesn't exist.
 
80
 *
 
81
 * Side effects:
 
82
 *      A directory is created.
 
83
 *
 
84
 *---------------------------------------------------------------------------
 
85
 */
 
86
 
 
87
int
 
88
SciCreateDirectory (
 
89
                     char *path)        /* Pathname of directory to create */
 
90
{
 
91
  int error;
 
92
 
 
93
  if (CreateDirectory (path, NULL) == 0)
 
94
    {
 
95
      error = GetLastError ();
 
96
      if (SciWinGetPlatformId () == VER_PLATFORM_WIN32s)
 
97
        {
 
98
          if ((error == ERROR_ACCESS_DENIED)
 
99
              && (GetFileAttributes (path) != (DWORD) - 1))
 
100
            {
 
101
              error = ERROR_FILE_EXISTS;
 
102
            }
 
103
        }
 
104
      SciWinConvertError (error);
 
105
      if (errno == EEXIST)
 
106
        {
 
107
          return SCI_OK;
 
108
        }
 
109
      sciprint ("Cannot create directory %s\r\n", path);
 
110
      return SCI_ERROR;
 
111
    }
 
112
  return SCI_OK;
 
113
}
 
114
 
 
115
 
 
116
 
 
117
/*
 
118
 *----------------------------------------------------------------------
 
119
 *
 
120
 * SciRemoveDirectory -- 
 
121
 *
 
122
 *      Removes directory (and its contents, if the recursive flag is set).
 
123
 *
 
124
 * Results:
 
125
 *      If the directory was successfully removed, returns SCI_OK.
 
126
 *      Otherwise the return value is SCI_ERROR, errno is set to indicate
 
127
 *      the error, and the pathname of the file that caused the error
 
128
 *      is stored in errorPtr.  Some possible values for errno are:
 
129
 *
 
130
 *      EACCES:     path directory can't be read and/or written.
 
131
 *      EEXIST:     path is a non-empty directory.
 
132
 *      EINVAL:     path is root directory or current directory.
 
133
 *      ENOENT:     path doesn't exist or is "".
 
134
 *      ENOTDIR:    path is not a directory.
 
135
 *
 
136
 *      EACCES:     path is a char device (nul:, com1:, etc.) (95)
 
137
 *      EINVAL:     path is a char device (nul:, com1:, etc.) (NT)
 
138
 *
 
139
 * Side effects:
 
140
 *      Directory removed.  If an error occurs, the error will be returned
 
141
 *      immediately, and remaining files will not be deleted.
 
142
 *
 
143
 *----------------------------------------------------------------------
 
144
 */
 
145
 
 
146
int 
 
147
SciRemoveDirectory (
 
148
                     char *path)        /* Pathname of directory to be removed. */
 
149
{
 
150
  Sci_DString errorPtr;
 
151
  Sci_DStringInit (&errorPtr);
 
152
  if (ScipRemoveDirectory (path, 1, &errorPtr) == SCI_ERROR)
 
153
    {
 
154
      sciprint ("Cannot remove directory %s\r\n", errorPtr.string);
 
155
    }
 
156
  Sci_DStringFree (&errorPtr);
 
157
  return 0;
 
158
}
 
159
 
 
160
 
 
161
 
 
162
/*
 
163
 *---------------------------------------------------------------------------
 
164
 *
 
165
 * ScipDeleteFile --
 
166
 *
 
167
 *      Removes a single file (not a directory).
 
168
 *
 
169
 * Results:
 
170
 *      If the file was successfully deleted, returns SCI_OK.  Otherwise
 
171
 *      the return value is SCI_ERROR and errno is set to indicate the
 
172
 *      error.  Some possible values for errno are:
 
173
 *
 
174
 *      EACCES:     a parent directory can't be read and/or written.
 
175
 *      EISDIR:     path is a directory.
 
176
 *      ENOENT:     path doesn't exist or is "".
 
177
 *
 
178
 *      EACCES:     exists an open file already referring to path.
 
179
 *      EACCES:     path is a char device (nul:, com1:, etc.)
 
180
 *
 
181
 * Side effects:
 
182
 *      The file is deleted, even if it is read-only.
 
183
 *
 
184
 *---------------------------------------------------------------------------
 
185
 */
 
186
 
 
187
int
 
188
ScipDeleteFile (
 
189
                 char *path)    /* Pathname of file to be removed. */
 
190
{
 
191
  DWORD attr;
 
192
 
 
193
  if (DeleteFile (path) != FALSE)
 
194
    {
 
195
      return SCI_OK;
 
196
    }
 
197
  SciWinConvertError (GetLastError ());
 
198
  if (path[0] == '\0')
 
199
    {
 
200
      /*
 
201
       * Win32s thinks that "" is the same as "." and then reports EISDIR
 
202
       * instead of ENOENT.
 
203
       */
 
204
 
 
205
      errno = ENOENT;
 
206
    }
 
207
  else if (errno == EACCES)
 
208
    {
 
209
      attr = GetFileAttributes (path);
 
210
      if (attr != (DWORD) - 1)
 
211
        {
 
212
          if (attr & FILE_ATTRIBUTE_DIRECTORY)
 
213
            {
 
214
              /*
 
215
               * Windows NT reports removing a directory as EACCES instead
 
216
               * of EISDIR.
 
217
               */
 
218
 
 
219
              errno = EISDIR;
 
220
            }
 
221
          else if (attr & FILE_ATTRIBUTE_READONLY)
 
222
            {
 
223
              SetFileAttributes (path, attr & ~FILE_ATTRIBUTE_READONLY);
 
224
              if (DeleteFile (path) != FALSE)
 
225
                {
 
226
                  return SCI_OK;
 
227
                }
 
228
              SciWinConvertError (GetLastError ());
 
229
              SetFileAttributes (path, attr);
 
230
            }
 
231
        }
 
232
    }
 
233
  else if (errno == ENOENT)
 
234
    {
 
235
      attr = GetFileAttributes (path);
 
236
      if (attr != (DWORD) - 1)
 
237
        {
 
238
          if (attr & FILE_ATTRIBUTE_DIRECTORY)
 
239
            {
 
240
              /*
 
241
               * Windows 95 reports removing a directory as ENOENT instead 
 
242
               * of EISDIR. 
 
243
               */
 
244
 
 
245
              errno = EISDIR;
 
246
            }
 
247
        }
 
248
    }
 
249
  else if (errno == EINVAL)
 
250
    {
 
251
      /*
 
252
       * Windows NT reports removing a char device as EINVAL instead of
 
253
       * EACCES.
 
254
       */
 
255
 
 
256
      errno = EACCES;
 
257
    }
 
258
 
 
259
  return SCI_ERROR;
 
260
}
 
261
 
 
262
/*
 
263
 *----------------------------------------------------------------------
 
264
 *
 
265
 * ScipRemoveDirectory -- 
 
266
 *
 
267
 *      Removes directory (and its contents, if the recursive flag is set).
 
268
 *
 
269
 * Results:
 
270
 *      If the directory was successfully removed, returns SCI_OK.
 
271
 *      Otherwise the return value is SCI_ERROR, errno is set to indicate
 
272
 *      the error, and the pathname of the file that caused the error
 
273
 *      is stored in errorPtr.  Some possible values for errno are:
 
274
 *
 
275
 *      EACCES:     path directory can't be read and/or written.
 
276
 *      EEXIST:     path is a non-empty directory.
 
277
 *      EINVAL:     path is root directory or current directory.
 
278
 *      ENOENT:     path doesn't exist or is "".
 
279
 *      ENOTDIR:    path is not a directory.
 
280
 *
 
281
 *      EACCES:     path is a char device (nul:, com1:, etc.) (95)
 
282
 *      EINVAL:     path is a char device (nul:, com1:, etc.) (NT)
 
283
 *
 
284
 * Side effects:
 
285
 *      Directory removed.  If an error occurs, the error will be returned
 
286
 *      immediately, and remaining files will not be deleted.
 
287
 *
 
288
 *----------------------------------------------------------------------
 
289
 */
 
290
 
 
291
int
 
292
ScipRemoveDirectory (
 
293
                      char *path,       /* Pathname of directory to be removed. */
 
294
                      int recursive,    /* If non-zero, removes directories that
 
295
                                         * are nonempty.  Otherwise, will only remove
 
296
                                         * empty directories. */
 
297
                      Sci_DString * errorPtr)   /* If non-NULL, initialized DString for
 
298
                                                 * error reporting. */
 
299
{
 
300
  int result;
 
301
  Sci_DString buffer;
 
302
  DWORD attr;
 
303
 
 
304
  if (RemoveDirectory (path) != FALSE)
 
305
    {
 
306
      return SCI_OK;
 
307
    }
 
308
  SciWinConvertError (GetLastError ());
 
309
  if (path[0] == '\0')
 
310
    {
 
311
      /*
 
312
       * Win32s thinks that "" is the same as "." and then reports EACCES
 
313
       * instead of ENOENT.
 
314
       */
 
315
 
 
316
      errno = ENOENT;
 
317
    }
 
318
  if (errno == EACCES)
 
319
    {
 
320
      attr = GetFileAttributes (path);
 
321
      if (attr != (DWORD) - 1)
 
322
        {
 
323
          if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
 
324
            {
 
325
              /* 
 
326
               * Windows 95 reports calling RemoveDirectory on a file as an 
 
327
               * EACCES, not an ENOTDIR.
 
328
               */
 
329
 
 
330
              errno = ENOTDIR;
 
331
              goto end;
 
332
            }
 
333
 
 
334
          if (attr & FILE_ATTRIBUTE_READONLY)
 
335
            {
 
336
              attr &= ~FILE_ATTRIBUTE_READONLY;
 
337
              if (SetFileAttributes (path, attr) == FALSE)
 
338
                {
 
339
                  goto end;
 
340
                }
 
341
              if (RemoveDirectory (path) != FALSE)
 
342
                {
 
343
                  return SCI_OK;
 
344
                }
 
345
              SciWinConvertError (GetLastError ());
 
346
              SetFileAttributes (path, attr | FILE_ATTRIBUTE_READONLY);
 
347
            }
 
348
 
 
349
          /* 
 
350
           * Windows 95 and Win32s report removing a non-empty directory 
 
351
           * as EACCES, not EEXIST.  If the directory is not empty,
 
352
           * change errno so caller knows what's going on.
 
353
           */
 
354
 
 
355
          if (SciWinGetPlatformId () != VER_PLATFORM_WIN32_NT)
 
356
            {
 
357
              HANDLE handle;
 
358
              WIN32_FIND_DATA data;
 
359
              Sci_DString buffer;
 
360
              char *find;
 
361
              int len;
 
362
 
 
363
              Sci_DStringInit (&buffer);
 
364
              find = Sci_DStringAppend (&buffer, path, -1);
 
365
              len = Sci_DStringLength (&buffer);
 
366
              if ((len > 0) && (find[len - 1] != '\\'))
 
367
                {
 
368
                  Sci_DStringAppend (&buffer, "\\", 1);
 
369
                }
 
370
              find = Sci_DStringAppend (&buffer, "*.*", 3);
 
371
              handle = FindFirstFile (find, &data);
 
372
              if (handle != INVALID_HANDLE_VALUE)
 
373
                {
 
374
                  while (1)
 
375
                    {
 
376
                      if ((strcmp (data.cFileName, ".") != 0)
 
377
                          && (strcmp (data.cFileName, "..") != 0))
 
378
                        {
 
379
                          /*
 
380
                           * Found something in this directory.
 
381
                           */
 
382
 
 
383
                          errno = EEXIST;
 
384
                          break;
 
385
                        }
 
386
                      if (FindNextFile (handle, &data) == FALSE)
 
387
                        {
 
388
                          break;
 
389
                        }
 
390
                    }
 
391
                  FindClose (handle);
 
392
                }
 
393
              Sci_DStringFree (&buffer);
 
394
            }
 
395
        }
 
396
    }
 
397
  if (errno == ENOTEMPTY)
 
398
    {
 
399
      /* 
 
400
       * The caller depends on EEXIST to signify that the directory is
 
401
       * not empty, not ENOTEMPTY. 
 
402
       */
 
403
 
 
404
      errno = EEXIST;
 
405
    }
 
406
  if ((recursive != 0) && (errno == EEXIST))
 
407
    {
 
408
      /*
 
409
       * The directory is nonempty, but the recursive flag has been
 
410
       * specified, so we recursively remove all the files in the directory.
 
411
       */
 
412
 
 
413
      Sci_DStringInit (&buffer);
 
414
      Sci_DStringAppend (&buffer, path, -1);
 
415
      result = TraverseWinTree (TraversalDelete, &buffer, NULL, errorPtr);
 
416
      Sci_DStringFree (&buffer);
 
417
      return result;
 
418
    }
 
419
 
 
420
end:
 
421
  if (errorPtr != NULL)
 
422
    {
 
423
      Sci_DStringAppend (errorPtr, path, -1);
 
424
    }
 
425
  return SCI_ERROR;
 
426
}
 
427
 
 
428
/*
 
429
 *---------------------------------------------------------------------------
 
430
 *
 
431
 * TraverseWinTree --
 
432
 *
 
433
 *      Traverse directory tree specified by sourcePtr, calling the function 
 
434
 *      traverseProc for each file and directory encountered.  If destPtr 
 
435
 *      is non-null, each of name in the sourcePtr directory is appended to 
 
436
 *      the directory specified by destPtr and passed as the second argument 
 
437
 *      to traverseProc() .
 
438
 *
 
439
 * Results:
 
440
 *      Standard Sci result.
 
441
 *
 
442
 * Side effects:
 
443
 *      None caused by TraverseWinTree, however the user specified 
 
444
 *      traverseProc() may change state.  If an error occurs, the error will
 
445
 *      be returned immediately, and remaining files will not be processed.
 
446
 *
 
447
 *---------------------------------------------------------------------------
 
448
 */
 
449
 
 
450
static int
 
451
TraverseWinTree (
 
452
                  TraversalProc * traverseProc,         /* Function to call for every file and
 
453
                                                         * directory in source hierarchy. */
 
454
                  Sci_DString * sourcePtr,      /* Pathname of source directory to be
 
455
                                                 * traversed. */
 
456
                  Sci_DString * targetPtr,      /* Pathname of directory to traverse in
 
457
                                                 * parallel with source directory. */
 
458
                  Sci_DString * errorPtr)       /* If non-NULL, an initialized DString for
 
459
                                                 * error reporting. */
 
460
{
 
461
  DWORD sourceAttr;
 
462
  char *source, *target, *errfile;
 
463
  int result, sourceLen, targetLen, sourceLenOriginal, targetLenOriginal;
 
464
  HANDLE handle;
 
465
  WIN32_FIND_DATA data;
 
466
 
 
467
  result = SCI_OK;
 
468
  source = Sci_DStringValue (sourcePtr);
 
469
  sourceLenOriginal = Sci_DStringLength (sourcePtr);
 
470
  if (targetPtr != NULL)
 
471
    {
 
472
      target = Sci_DStringValue (targetPtr);
 
473
      targetLenOriginal = Sci_DStringLength (targetPtr);
 
474
    }
 
475
  else
 
476
    {
 
477
      target = NULL;
 
478
      targetLenOriginal = 0;
 
479
    }
 
480
 
 
481
  errfile = NULL;
 
482
 
 
483
  sourceAttr = GetFileAttributes (source);
 
484
  if (sourceAttr == (DWORD) - 1)
 
485
    {
 
486
      errfile = source;
 
487
      goto end;
 
488
    }
 
489
  if ((sourceAttr & FILE_ATTRIBUTE_DIRECTORY) == 0)
 
490
    {
 
491
      /*
 
492
       * Process the regular file
 
493
       */
 
494
 
 
495
      return (*traverseProc) (source, target, sourceAttr, DOTREE_F, errorPtr);
 
496
    }
 
497
 
 
498
  /*
 
499
   * When given the pathname of the form "c:\" (one that already ends
 
500
   * with a backslash), must make sure not to add another "\" to the end
 
501
   * otherwise it will try to access a network drive.  
 
502
   */
 
503
 
 
504
  sourceLen = sourceLenOriginal;
 
505
  if ((sourceLen > 0) && (source[sourceLen - 1] != '\\'))
 
506
    {
 
507
      Sci_DStringAppend (sourcePtr, "\\", 1);
 
508
      sourceLen++;
 
509
    }
 
510
  source = Sci_DStringAppend (sourcePtr, "*.*", 3);
 
511
  handle = FindFirstFile (source, &data);
 
512
  Sci_DStringSetLength (sourcePtr, sourceLen);
 
513
  if (handle == INVALID_HANDLE_VALUE)
 
514
    {
 
515
      /* 
 
516
       * Can't read directory
 
517
       */
 
518
 
 
519
      SciWinConvertError (GetLastError ());
 
520
      errfile = source;
 
521
      goto end;
 
522
    }
 
523
 
 
524
  result = (*traverseProc) (source, target, sourceAttr, DOTREE_PRED, errorPtr);
 
525
  if (result != SCI_OK)
 
526
    {
 
527
      FindClose (handle);
 
528
      return result;
 
529
    }
 
530
 
 
531
  if (targetPtr != NULL)
 
532
    {
 
533
      targetLen = targetLenOriginal;
 
534
      if ((targetLen > 0) && (target[targetLen - 1] != '\\'))
 
535
        {
 
536
          target = Sci_DStringAppend (targetPtr, "\\", 1);
 
537
          targetLen++;
 
538
        }
 
539
    }
 
540
 
 
541
  while (1)
 
542
    {
 
543
      if ((strcmp (data.cFileName, ".") != 0)
 
544
          && (strcmp (data.cFileName, "..") != 0))
 
545
        {
 
546
          /* 
 
547
           * Append name after slash, and recurse on the file. 
 
548
           */
 
549
 
 
550
          Sci_DStringAppend (sourcePtr, data.cFileName, -1);
 
551
          if (targetPtr != NULL)
 
552
            {
 
553
              Sci_DStringAppend (targetPtr, data.cFileName, -1);
 
554
            }
 
555
          result = TraverseWinTree (traverseProc, sourcePtr, targetPtr,
 
556
                                    errorPtr);
 
557
          if (result != SCI_OK)
 
558
            {
 
559
              break;
 
560
            }
 
561
 
 
562
          /*
 
563
           * Remove name after slash.
 
564
           */
 
565
 
 
566
          Sci_DStringSetLength (sourcePtr, sourceLen);
 
567
          if (targetPtr != NULL)
 
568
            {
 
569
              Sci_DStringSetLength (targetPtr, targetLen);
 
570
            }
 
571
        }
 
572
      if (FindNextFile (handle, &data) == FALSE)
 
573
        {
 
574
          break;
 
575
        }
 
576
    }
 
577
  FindClose (handle);
 
578
 
 
579
  /*
 
580
   * Strip off the trailing slash we added
 
581
   */
 
582
 
 
583
  Sci_DStringSetLength (sourcePtr, sourceLenOriginal);
 
584
  source = Sci_DStringValue (sourcePtr);
 
585
  if (targetPtr != NULL)
 
586
    {
 
587
      Sci_DStringSetLength (targetPtr, targetLenOriginal);
 
588
      target = Sci_DStringValue (targetPtr);
 
589
    }
 
590
 
 
591
  if (result == SCI_OK)
 
592
    {
 
593
      /*
 
594
       * Call traverseProc() on a directory after visiting all the
 
595
       * files in that directory.
 
596
       */
 
597
 
 
598
      result = (*traverseProc) (source, target, sourceAttr,
 
599
                                DOTREE_POSTD, errorPtr);
 
600
    }
 
601
end:
 
602
  if (errfile != NULL)
 
603
    {
 
604
      SciWinConvertError (GetLastError ());
 
605
      if (errorPtr != NULL)
 
606
        {
 
607
          Sci_DStringAppend (errorPtr, errfile, -1);
 
608
        }
 
609
      result = SCI_ERROR;
 
610
    }
 
611
 
 
612
  return result;
 
613
}
 
614
 
 
615
/*
 
616
 *----------------------------------------------------------------------
 
617
 *
 
618
 * TraversalDelete --
 
619
 *
 
620
 *      Called by procedure TraverseWinTree for every file and
 
621
 *      directory that it encounters in a directory hierarchy. This
 
622
 *      procedure unlinks files, and removes directories after all the
 
623
 *      containing files have been processed.
 
624
 *
 
625
 * Results:
 
626
 *      Standard Sci result.
 
627
 *
 
628
 * Side effects:
 
629
 *      Files or directory specified by src will be deleted. If an
 
630
 *      error occurs, the windows error is converted to a Posix error
 
631
 *      and errno is set accordingly.
 
632
 *
 
633
 *----------------------------------------------------------------------
 
634
 */
 
635
 
 
636
static int
 
637
TraversalDelete (
 
638
                  char *src,    /* Source pathname. */
 
639
                  char *ignore, /* Destination pathname (not used). */
 
640
                  DWORD srcAttr,        /* File attributes for src (not used). */
 
641
                  int type,     /* Reason for call - see TraverseWinTree(). */
 
642
                  Sci_DString * errorPtr)       /* If non-NULL, initialized DString for
 
643
                                                 * error return. */
 
644
{
 
645
  switch (type)
 
646
    {
 
647
    case DOTREE_F:
 
648
      if (ScipDeleteFile (src) == SCI_OK)
 
649
        {
 
650
          return SCI_OK;
 
651
        }
 
652
      break;
 
653
 
 
654
    case DOTREE_PRED:
 
655
      return SCI_OK;
 
656
 
 
657
    case DOTREE_POSTD:
 
658
      if (ScipRemoveDirectory (src, 0, NULL) == SCI_OK)
 
659
        {
 
660
          return SCI_OK;
 
661
        }
 
662
      break;
 
663
 
 
664
    }
 
665
 
 
666
  if (errorPtr != NULL)
 
667
    {
 
668
      Sci_DStringAppend (errorPtr, src, -1);
 
669
    }
 
670
  return SCI_ERROR;
 
671
}