diff options
author | Jan Dubois <jand@activestate.com> | 1999-02-09 23:27:31 +0100 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-15 06:38:15 +0000 |
commit | ca1356241e9bcc3f64c025dfdaeeb9056d931517 (patch) | |
tree | f732e9435d48c9849180db7d242db5b3d0ffdb11 /win32 | |
parent | ef54e1a45e68bbd668c909c97e266f20578d5516 (diff) | |
download | perl-ca1356241e9bcc3f64c025dfdaeeb9056d931517.tar.gz |
support Win32::GetFullPathName() and Win32::SetLastError()
Message-ID: <36c1a2ed.8007554@smtp1.ibm.net>
Subject: [PATCH _54] Win32::GetFullPathName (Re: File::Spec::Win32 and UNCs)
p4raw-id: //depot/perl@2937
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c index 7b9acd4a8f..7b328e9e5a 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2280,6 +2280,16 @@ XS(w32_GetLastError) } static +XS(w32_SetLastError) +{ + dXSARGS; + if (items != 1) + croak("usage: Win32::SetLastError($error)"); + SetLastError(SvIV(ST(0))); + XSRETURN_UNDEF; +} + +static XS(w32_LoginName) { dXSARGS; @@ -2496,6 +2506,42 @@ XS(w32_GetShortPathName) } static +XS(w32_GetFullPathName) +{ + dXSARGS; + SV *filename; + SV *fullpath; + char *filepart; + DWORD len; + + if (items != 1) + croak("usage: Win32::GetFullPathName($filename)"); + + filename = ST(0); + fullpath = sv_mortalcopy(filename); + SvUPGRADE(fullpath, SVt_PV); + do { + len = GetFullPathName(SvPVX(filename), + SvLEN(fullpath), + SvPVX(fullpath), + &filepart); + } while (len >= SvLEN(fullpath) && sv_grow(fullpath,len+1)); + if (len) { + if (GIMME_V == G_ARRAY) { + EXTEND(SP,1); + ST(1) = sv_2mortal(newSVpv(filepart,0)); + len = filepart - SvPVX(fullpath); + items = 2; + } + SvCUR_set(fullpath,len); + ST(0) = fullpath; + } + else + ST(0) = &PL_sv_undef; + XSRETURN(items); +} + +static XS(w32_Sleep) { dXSARGS; @@ -2523,6 +2569,7 @@ Perl_init_os_extras() newXS("Win32::SetCwd", w32_SetCwd, file); newXS("Win32::GetNextAvailDrive", w32_GetNextAvailDrive, file); newXS("Win32::GetLastError", w32_GetLastError, file); + newXS("Win32::SetLastError", w32_SetLastError, file); newXS("Win32::LoginName", w32_LoginName, file); newXS("Win32::NodeName", w32_NodeName, file); newXS("Win32::DomainName", w32_DomainName, file); @@ -2534,6 +2581,7 @@ Perl_init_os_extras() newXS("Win32::Spawn", w32_Spawn, file); newXS("Win32::GetTickCount", w32_GetTickCount, file); newXS("Win32::GetShortPathName", w32_GetShortPathName, file); + newXS("Win32::GetFullPathName", w32_GetFullPathName, file); newXS("Win32::Sleep", w32_Sleep, file); /* XXX Bloat Alert! The following Activeware preloads really |