~ubuntu-branches/ubuntu/karmic/isomaster/karmic

« back to all changes in this revision

Viewing changes to bk/bkAdd.c

  • Committer: Bazaar Package Importer
  • Author(s): David Johnson
  • Date: 2007-12-18 21:11:57 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20071218211157-xwhlx6o2r7d0en9q
Tags: 1.3-1
* New upstream release
* Update to standards version 3.7.3
* Fix watch file for rc filename variations

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
13
13
******************************************************************************/
14
14
 
15
 
#ifndef WIN32
16
 
    #include <dirent.h>
17
 
#else
18
 
    #define _CRT_SECURE_NO_WARNINGS 1
19
 
#endif
 
15
#include <dirent.h>
20
16
#include <sys/types.h>
21
17
#include <sys/stat.h>
22
18
#include <stdlib.h>
32
28
#include "bkLink.h"
33
29
#include "bkMisc.h"
34
30
#include "bkSet.h"
 
31
#include "bkIoWrappers.h"
35
32
 
36
33
int add(VolInfo* volInfo, const char* srcPathAndName, BkDir* destDir, 
37
34
        const char* nameToUse)
39
36
    int rc;
40
37
    char lastName[NCHARS_FILE_ID_MAX_STORE];
41
38
    BkFileBase* oldHead; /* of the children list */
42
 
    struct stat statStruct;
 
39
    BkStatStruct statStruct;
43
40
    
44
41
    if(volInfo->stopOperation)
45
42
        return BKERROR_OPER_CANCELED_BY_USER;
67
64
    
68
65
    oldHead = destDir->children;
69
66
    
70
 
#ifndef WIN32
 
67
    /* windows doesn't have symbolic links */
71
68
    if(volInfo->followSymLinks)
72
 
#endif
73
 
        rc = stat(srcPathAndName, &statStruct);
74
 
#ifndef WIN32 //!!WIN32
75
 
    /* windows doesn't have symbolic links anyway */
 
69
        rc = bkStat(srcPathAndName, &statStruct);
76
70
    else
77
71
        rc = lstat(srcPathAndName, &statStruct);
78
 
#endif
79
72
    if(rc == -1)
80
73
        return BKERROR_STAT_FAILED;
81
74
    
166
159
        
167
160
        destDir->children = BK_BASE_PTR(newFile);
168
161
    }
169
 
#ifndef WIN32
170
162
    else if( IS_SYMLINK(statStruct.st_mode) )
171
163
    {
172
164
        BkSymLink* newSymLink;
195
187
        
196
188
        destDir->children = BK_BASE_PTR(newSymLink);
197
189
    }
198
 
#endif
199
190
    else
200
191
        return BKERROR_NO_SPECIAL_FILES;
201
192
    
202
193
    return 1;
203
194
}
204
195
 
205
 
//needs a rewrite for windows //!!WIN32
206
196
int addDirContents(VolInfo* volInfo, const char* srcPath, BkDir* destDir)
207
197
{
208
198
    int rc;
216
206
    srcPathLen = strlen(srcPath);
217
207
    
218
208
    /* including the new name and the possibly needed trailing '/' */
219
 
    newSrcPathAndName = malloc(srcPathLen + NCHARS_FILE_ID_MAX_STORE + 1);
 
209
    newSrcPathAndName = malloc(srcPathLen + NCHARS_FILE_ID_MAX_STORE + 2);
220
210
    if(newSrcPathAndName == NULL)
221
211
        return BKERROR_OUT_OF_MEMORY;
222
212
    
223
213
    strcpy(newSrcPathAndName, srcPath);
 
214
    
224
215
    if(srcPath[srcPathLen - 1] != '/')
225
216
    {
226
217
        strcat(newSrcPathAndName, "/");
356
347
int bk_add_boot_record(VolInfo* volInfo, const char* srcPathAndName, 
357
348
                       int bootMediaType)
358
349
{
359
 
    struct stat statStruct;
 
350
    BkStatStruct statStruct;
360
351
    int rc;
361
352
    
362
353
    if(bootMediaType != BOOT_MEDIA_NO_EMULATION &&
367
358
        return BKERROR_ADD_UNKNOWN_BOOT_MEDIA;
368
359
    }
369
360
    
370
 
    rc = stat(srcPathAndName, &statStruct);
 
361
    rc = bkStat(srcPathAndName, &statStruct);
371
362
    if(rc == -1)
372
363
        return BKERROR_STAT_FAILED;
373
364
    
 
365
    if(statStruct.st_size > 0xFFFFFFFF)
 
366
    /* size won't fit in a 32bit variable on the iso */
 
367
        return BKERROR_ADD_FILE_TOO_BIG;
 
368
    
374
369
    if( (bootMediaType == BOOT_MEDIA_1_2_FLOPPY &&
375
370
         statStruct.st_size != 1228800) ||
376
371
        (bootMediaType == BOOT_MEDIA_1_44_FLOPPY &&