Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863

    File.GetShortName() on already short names.

    See the image -- when using short names to File.GetShortName() I'm getting garbage...


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    god d.a.m man, how short do you want that path

    if using the API direct it works ok, so its an AMS bug for sure, and i guess bugs need fixing

    here, try THIS air code
    Code:
    function GetShortPath(sPath)
    	local _LongPath = Memory.Allocate(1024);
    	local _ShortPath = Memory.Allocate(1024);
    	Memory.PutString(_LongPath, sPath, -1, "Ascii");
    	local ret = DLL.CallFunction("Kernel32.dll", "GetShortPathNameA", _LongPath..",".._ShortPath..",1024", DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL);
    	local sShortPath = Memory.GetString(_ShortPath, -1, "Ascii");
    	Memory.Free(_LongPath);
    	Memory.Free(_ShortPath);
    	return sShortPath
    end
    
    sLong="C:\\Users\\Dean\\Documents\\Battlefield Heroes\\PersistentStorage.dat"
    sShort=GetShortPath(sLong)
    Dialog.Message("Notice", sShort);
    Dialog.Message("Notice", GetShortPath(sShort));
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    It's not that I need it shorter, it's that I wanted to ensure it was short.Calling the API yields expected results "untouched".


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  4. #4
    Join Date
    Jul 2001
    Location
    Indigo Rose Software
    Posts
    1,834
    The problem is caused by the fact the API call that is used is "GetShortPathName" which requires that the file exist at the location in order to get its short path name. I'm assuming in your test it did not, and I have confirmed that it does work in both cases if it exists.

    The problems on our end that will be fixed were that we were not returning an empty string on failure and the help did not reflect this information. These will be updated.
    Darryl
    Indigo Rose Corporation

    Product Guides: AMS80 | SUF9 | TU30 | VP30 |MSIFACT |DeltaMAX

  5. #5
    Join Date
    May 2006
    Posts
    5,380
    and I have confirmed that it does work in both cases if it exists.
    me too, i dident test it before now, i just took it for granted it dident work (that will teach me)

    Josh, i just tried the below code, with a file that does exist

    Code:
    sLong="C:\\Users\\Dean\\Documents\\Battlefield Heroes\\PersistentStorage.dat"
    sShort=File.GetShortName(sLong);
    Debug.Print(sShort.."\r\n");
    Debug.Print(File.GetShortName(sShort).."\r\n");
    and the result was
    Code:
    C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT
    C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT
    so in my test it returns exactly the same as the API call
    Code:
    C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT
    C:\Users\Dean\DOCUME~1\BATTLE~1\PERSIS~1.DAT
    and if its a file that does not exist, then its garbage like you said (maybe junk from the memory buffer), the API call tho returns a blank string
    Open your eyes to Narcissism, Don't let her destroy your life!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts