38 #if defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) // up to VS2003 39 _splitpath( path, temp_drive, temp_dir, temp_fname, temp_ext );
40 #else // VS2005 using MS STL, boooooo 41 _splitpath_s( path, temp_drive, MAXDRIVE, temp_dir, MAXDIR, temp_fname, MAXFILE, temp_ext,
46 return fnsplit( path, temp_drive, temp_dir, temp_fname, temp_ext );
54 #if defined( _MSC_VER ) && ( _MSC_VER <= 1310 ) // up to VS2003 55 _makepath( path, temp_drive, temp_dir, temp_fname, temp_ext );
56 #else // VS2005 using MS STL, booooo 57 _makepath_s( path, MAXPATH, temp_drive, temp_dir, temp_fname, temp_ext );
60 fnmerge( path, temp_drive, temp_dir, temp_fname, temp_ext );
67 strzcpy( fname, temp_fname, MAXFILE );
68 strncat( fname, temp_ext, MAXEXT - 1 );
79 int ch = toupper( dir[0] );
94 const char* use_fname;
95 const char* use_template;
97 void find_usefns(
const char* dir,
const char* fname )
105 if ( fname && fname[0] )
112 const char* s = strrchr( use_dir,
'\\' );
114 s = strrchr( use_dir,
'/' );
116 if ( s != NULL && ( s[1] ==
'\0' ) )
117 use_template =
"%s%s";
119 use_template =
"%s\\%s";
123 char*
nodefile(
const char* directory,
const char* filename,
int node )
126 find_usefns( directory, filename );
127 sprintf( buf,
"%s.%%d", use_template );
128 sprintf( workspace2, buf, directory, filename, node );
129 _fullpath( fullpath2, workspace2,
sizeof fullpath2 );
134 char*
buildfn(
const char* directory,
const char* filename )
137 find_usefns( directory, filename );
138 sprintf( workspace2, use_template, use_dir, use_fname );
139 _fullpath( fullpath2, workspace2,
sizeof fullpath2 );
144 char*
buildfnext(
const char* directory,
const char* filename,
const char* extension )
146 find_usefns( directory, filename );
147 sprintf( workspace2, use_template, directory, filename );
148 strcat( workspace2,
"." );
149 strncat( workspace2, extension, 3 );
150 _fullpath( fullpath2, workspace2,
sizeof fullpath2 );
161 char* s = strrchr( dir,
'\\' );
164 if ( *( s + 1 ) ==
'\0' )
172 static int inner_copy(
const char* src,
const char* dst,
int replaceOk )
174 int in = -1, out = -1;
180 for ( bufsize = 0x4000; buf == NULL && bufsize >= 128; bufsize /= 2 )
181 buf = malloc( bufsize );
184 static char dummy[4];
190 in = open( src, O_RDONLY | O_BINARY );
193 out = open( dst, O_BINARY | O_CREAT | O_RDWR | ( replaceOk ? O_TRUNC : O_EXCL ),
194 S_IREAD | S_IWRITE );
197 int lastwrite, nbytes;
198 while ( ( nbytes = read( in, buf, bufsize ) ) > 0 )
200 lastwrite = write( out, buf, nbytes );
201 if ( lastwrite == -1 )
204 if ( lastwrite >= 0 )
211 getftime( in, &ftime );
212 setftime( out, &ftime );
267 static int inner_move(
const char* src,
const char* dst,
int replaceOk )
269 if ( replaceOk && access( dst, 0 ) == 0 )
271 if ( rename( src, dst ) == 0 )
273 else if (
inner_copy( src, dst, replaceOk ) == 0 )
static Pathname workspace2
int moveFileNoRep(const char *src, const char *dst)
int copyFileNoRep(const char *src, const char *dst)
char * buildfnext(const char *directory, const char *filename, const char *extension)
char * buildfn(const char *directory, const char *filename)
int moveFile(const char *src, const char *dst)
char temp_drive[MAXDRIVE]
static int inner_move(const char *src, const char *dst, int replaceOk)
void normalize_dir(char *dir)
int copyFile(const char *src, const char *dst)
int chddir(const char *dir)
char * nodefile(const char *directory, const char *filename, int node)
static int inner_copy(const char *src, const char *dst, int replaceOk)
char * fullmerge(char *path)
int fullsplit(const char *path)
static Pathname fullpath2
char * mergeFnExt(char *fname)