Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by Anonymous Monk
on Oct 08, 2012 at 15:51 UTC ( #997842=note: print w/ replies, xml ) Need Help??


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

Win32::StrictFileNames does that

$ perl -Mcgi -e 1 $ perl -Mwin32::strictfileNames -e 1 $ perl -Mwin32::strictfileNames -Mcgi -e 1 Can't locate cgi.pm in @INC (@INC contains:... $ perl -Mwin32::strictfileNames -Mcgi -e 1 Can't locate cgi.pm in @INC (@INC contains:...


Comment on Re^2: [Win32] Verify filename (case sensitively)
Download Code
Re^3: [Win32] Verify filename (case sensitively)
by syphilis (Canon) on Oct 09, 2012 at 00:26 UTC
    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
      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
      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://997842]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-10-02 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (49 votes), past polls