return pPerl->piLIO->NameStat(name, sbufptr, ErrorNo());
}
+int _win32_rename(const char *oldname, const char *newname)
+{
+ return pPerl->piLIO->Rename(oldname, newname, ErrorNo());
+}
+
int _win32_setmode(int fd, int mode)
{
return pPerl->piLIO->Setmode(fd, mode, ErrorNo());
#undef win32_pipe
#undef win32_popen
#undef win32_pclose
+#undef win32_rename
#undef win32_setmode
#undef win32_lseek
#undef win32_tell
#define win32_pipe _win32_pipe
#define win32_popen _win32_popen
#define win32_pclose _win32_pclose
+#define win32_rename _win32_rename
#define win32_setmode _win32_setmode
#define win32_lseek _win32_lseek
#define win32_tell _win32_tell
int _win32_pipe( int *phandles, unsigned int psize, int textmode );
FILE* _win32_popen( const char *command, const char *mode );
int _win32_pclose( FILE *pf);
+int _win32_rename( const char *oldname, const char *newname);
int _win32_setmode( int fd, int mode);
long _win32_lseek( int fd, long offset, int origin);
long _win32_tell( int fd);
win32_pipe
win32_popen
win32_pclose
+win32_rename
win32_setmode
win32_lseek
win32_tell
};
virtual int Rename(const char *OldFileName, const char *newname, int &err)
{
- char szNewWorkName[MAX_PATH+1];
- WIN32_FIND_DATA fdOldFile, fdNewFile;
- HANDLE handle;
- char *ptr;
-
- if((strchr(OldFileName, '\\') || strchr(OldFileName, '/'))
- && strchr(newname, '\\') == NULL
- && strchr(newname, '/') == NULL)
- {
- strcpy(szNewWorkName, OldFileName);
- if((ptr = strrchr(szNewWorkName, '\\')) == NULL)
- ptr = strrchr(szNewWorkName, '/');
- strcpy(++ptr, newname);
- }
- else
- strcpy(szNewWorkName, newname);
-
- if(stricmp(OldFileName, szNewWorkName) != 0)
- { // check that we're not being fooled by relative paths
- // and only delete the new file
- // 1) if it exists
- // 2) it is not the same file as the old file
- // 3) old file exist
- // GetFullPathName does not return the long file name on some systems
- handle = FindFirstFile(OldFileName, &fdOldFile);
- if(handle != INVALID_HANDLE_VALUE)
- {
- FindClose(handle);
-
- handle = FindFirstFile(szNewWorkName, &fdNewFile);
-
- if(handle != INVALID_HANDLE_VALUE)
- FindClose(handle);
- else
- fdNewFile.cFileName[0] = '\0';
-
- if(strcmp(fdOldFile.cAlternateFileName, fdNewFile.cAlternateFileName) != 0
- && strcmp(fdOldFile.cFileName, fdNewFile.cFileName) != 0)
- { // file exists and not same file
- DeleteFile(szNewWorkName);
- }
- }
- }
- int ret = rename(OldFileName, szNewWorkName);
- if(ret)
- err = errno;
-
- return ret;
+ CALLFUNCRET(win32_rename(OldFileName, newname))
};
virtual int Setmode(int handle, int mode, int &err)
{
get_emd_part(char *prev_path, char *trailing_path, ...)
{
va_list ap;
- char mod_name[MAX_PATH];
+ char mod_name[MAX_PATH+1];
char *ptr;
char *optr;
char *strip;
{
char *sitelib = "sitelib";
char regstr[40];
- char pathstr[MAX_PATH];
+ char pathstr[MAX_PATH+1];
DWORD datalen;
char *path1 = Nullch;
char *path2 = Nullch;
DllExport int
win32_stat(const char *path, struct stat *buffer)
{
- char t[MAX_PATH];
+ char t[MAX_PATH+1];
const char *p = path;
int l = strlen(path);
int res;
}
DllExport int
+win32_rename(const char *oldname, const char *newname)
+{
+ char szNewWorkName[MAX_PATH+1];
+ WIN32_FIND_DATA fdOldFile, fdNewFile;
+ HANDLE handle;
+ char *ptr;
+
+ if ((strchr(oldname, '\\') || strchr(oldname, '/'))
+ && strchr(newname, '\\') == NULL
+ && strchr(newname, '/') == NULL)
+ {
+ strcpy(szNewWorkName, oldname);
+ if ((ptr = strrchr(szNewWorkName, '\\')) == NULL)
+ ptr = strrchr(szNewWorkName, '/');
+ strcpy(++ptr, newname);
+ }
+ else
+ strcpy(szNewWorkName, newname);
+
+ if (stricmp(oldname, szNewWorkName) != 0) {
+ // check that we're not being fooled by relative paths
+ // and only delete the new file
+ // 1) if it exists
+ // 2) it is not the same file as the old file
+ // 3) old file exist
+ // GetFullPathName does not return the long file name on some systems
+ handle = FindFirstFile(oldname, &fdOldFile);
+ if (handle != INVALID_HANDLE_VALUE) {
+ FindClose(handle);
+
+ handle = FindFirstFile(szNewWorkName, &fdNewFile);
+
+ if (handle != INVALID_HANDLE_VALUE)
+ FindClose(handle);
+ else
+ fdNewFile.cFileName[0] = '\0';
+
+ if (strcmp(fdOldFile.cAlternateFileName,
+ fdNewFile.cAlternateFileName) != 0
+ && strcmp(fdOldFile.cFileName, fdNewFile.cFileName) != 0)
+ {
+ // file exists and not same file
+ DeleteFile(szNewWorkName);
+ }
+ }
+ }
+ return rename(oldname, newname);
+}
+
+DllExport int
win32_setmode(int fd, int mode)
{
return setmode(fd, mode);
DllExport int win32_pipe( int *phandles, unsigned int psize, int textmode );
DllExport FILE* win32_popen( const char *command, const char *mode );
DllExport int win32_pclose( FILE *pf);
+DllExport int win32_rename( const char *oldname, const char *newname);
DllExport int win32_setmode( int fd, int mode);
DllExport long win32_lseek( int fd, long offset, int origin);
DllExport long win32_tell( int fd);
#define abort() win32_abort()
#define fstat(fd,bufptr) win32_fstat(fd,bufptr)
#define stat(pth,bufptr) win32_stat(pth,bufptr)
+#define rename(old,new) win32_rename(old,new)
#define setmode(fd,mode) win32_setmode(fd,mode)
#define lseek(fd,offset,orig) win32_lseek(fd,offset,orig)
#define tell(fd) win32_tell(fd)