Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Don't ask to ask, just ask
 
PerlMonks  

Re^3: [Win32] Verify filename (case sensitively)

by syphilis (Canon)
on Oct 09, 2012 at 00:26 UTC ( #997903=note: print w/ replies, xml ) Need Help??


in reply to Re^2: [Win32] Verify filename (case sensitively)
in thread [Win32] Verify filename (case sensitively)

Win32::StrictFileNames does that

That seems to make use of GetLongPathName(), too.
It won't build successfully for me using mingw - all tests die with the following diagnostic:

t/7-rmdir.t ... Can't load 'C:\sisyphusion\Win32-StrictFileNames-0.01\blib\arch/ auto/Win32/StrictFileNames/StrictFileNames.dll' for module Win32::StrictFileNames: load_file:Invalid access to memory location at C:/MinGW/perl512/lib/DynaLoader.pm line 200.
at t/7-rmdir.t line 8

Update: And similar errors when building using an MS compiler (MSVC++-7.0) instead of gcc.

Also, I notice that the author provides, on his own ppm repo, packages for this module only for perls 5.6 and 5.8. (I don't know if that's because they pose a problem with later versions of perl.)

Does use Win32::StrictFileNames; catch *all* instances of case-mismatch (eg with '-e', 'open') ?

Looks like an interesting module to re-visit if I get the time (before I forget all about it :-).
For the moment, the Win32::GetLongPathName() function will suffice.

And interesting that, going by your example, the module itself works irrespective of the case that's used when loading it.

Cheers,
Rob


Comment on Re^3: [Win32] Verify filename (case sensitively)
Download Code
Re^4: [Win32] Verify filename (case sensitively)
by Anonymous Monk on Oct 09, 2012 at 02:49 UTC
    Well, it compiles for me with mingw32 gcc version 4.7.0 (GCC)
      Well, it compiles for me with mingw32 gcc version 4.7.0 (GCC)

      What's your perl -V (that's an uppercase 'V') output ?

      Afterthought: What OS are you running ? (I'm on Vista.)

      Cheers,
      Rob
        $ perl -MWin32 -le " print $^X; print Win32::GetOSDisplayName() C:\perl\5.14.1\bin\MSWin32-x86-multi-thread\perl.exe Windows XP Home Edition Service Pack 3
Re^4: [Win32] Verify filename (case sensitively)
by bulk88 (Priest) on Oct 09, 2012 at 05:14 UTC
    Compiler fine. No compiler warnings.
    Test Summary Report ------------------- t/2-exist.t (Wstat: 2304 Tests: 15 Failed: 9) Failed tests: 4-6, 8-11, 14-15 Non-zero exit status: 9 t/3-stat.t (Wstat: 2304 Tests: 15 Failed: 9) Failed tests: 4-6, 8-11, 14-15 Non-zero exit status: 9 t/4-dir.t (Wstat: 1792 Tests: 13 Failed: 7) Failed tests: 4-5, 7-9, 12-13 Non-zero exit status: 7 t/7-rmdir.t (Wstat: 2048 Tests: 14 Failed: 8) Failed tests: 2, 5, 7, 9-10, 12-14 Non-zero exit status: 8 Files=9, Tests=114, 2 wallclock secs ( 0.13 usr + 0.05 sys = 0.17 C +PU) Result: FAIL Failed 4/9 test programs. 33/114 subtests failed. NMAKE : fatal error U1077: 'C:\perl512\bin\perl.exe' : return code '0x +ff' Stop. C:\Documents and Settings\Owner\Desktop\cpan libs\Win32-StrictFileName +s-0.01>
    Can't load 'C:\sisyphusion\Win32-StrictFileNames-0.01\blib\arch/ auto/ +Win32/StrictFileNames/StrictFileNames.dll' for module Win32::StrictFi +leNames: load_file:Invalid access to memory location at C:/MinGW/perl +512/lib/DynaLoader.pm line 200.
    means something in DllMain did an access vio.

    1 minute later of research.

    // ========== Initialisation //-------------------------------------------------------------------- +--------- // DllMain() // Function called by the system when processes and threads are initia +lized // and terminated. //-------------------------------------------------------------------- +--------- BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpRese +rved) { BOOL bResult = TRUE; int i; char szMsvcrt[3][16] = { "MSVCRT.dll", "MSVCRT70.dll", "MSVCRT71.dll" }; switch( dwReason ) { case DLL_PROCESS_ATTACH: hDllInstance = hInstance; // save Dll instance handle DEBUGSTR("hDllInstance = 0x%.8x", hDllInstance); bResult &= HookAPIAllMod("KERNEL32.dll", "CreateFileA", (PROC)My +_CreateFileA); DEBUGSTR("CreateFileA = %d", bResult); bResult &= HookAPIAllMod("KERNEL32.dll", "GetFileAttributesA", ( +PROC)My_GetFileAttributesA); DEBUGSTR("GetFileAttributesA = %d", bResult); for (i=0; i<3; i++) { if ( GetModuleHandle(szMsvcrt[i]) ) { bResult &= HookAPIAllMod(szMsvcrt[i], "_stati64", (PROC)My_s +tati64); bResult &= HookAPIAllMod(szMsvcrt[i], "_stat", (PROC)My_stat +); bResult &= HookAPIAllMod(szMsvcrt[i], "_rmdir", (PROC)My_rmd +ir); bResult &= HookAPIAllMod(szMsvcrt[i], "_chdir", (PROC)My_chd +ir); DEBUGSTR("%s functions = %d", szMsvcrt[i], bResult); } } case DLL_PROCESS_DETACH: break; } return (bResult); }
    WHAT???!!!! I see a familiar friend, I guess I am not the first to do IAT patching with Perl in XS. I'm guessing bitrot/compiler/crt versions or x64 broke this module.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997903]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2014-04-21 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls