Re: file access again

new topic     » goto parent     » topic index » view thread      » older message » newer message
useless_ said...


Perhaps it's a shell problem. If i use system() to get a dir of writefilename, it also fails:

Running. 
The system cannot find the path specified. 
But if i open a cmd.exe myself, dir worked fine.

useless

Hallo

As i remeber situations where Windows just don't like my filenames. I often use this as a solution.

Maybe you can try to get the Short Name of your file and pass this name to open.

Quick'n Dirty code follows ;)

include std/dll.e 
include std/machine.e 
 
constant MAX_PATH    = 260 
constant kernel32 = open_dll ("kernel32.dll") 
constant myGetShortPathName=define_c_func(kernel32,"GetShortPathNameA",{C_POINTER,C_POINTER,C_UINT},C_INT) 
 
function ShortFileName(sequence filename) 
atom inszpointer,outszpointer 
object result 
    outszpointer=allocate(MAX_PATH+1) 
    inszpointer=allocate_string(filename) 
    c_func(myGetShortPathName,{inszpointer,outszpointer,MAX_PATH+1}) 
    result = peek_string(outszpointer) 
    free(outszpointer) 
    free(inszpointer) 
    return result 
end function 
 
 
-- Just for testing... 
puts(1,getenv("HOMEPATH")&"\n") 
puts(1,ShortFileName(getenv("HOMEPATH"))&"\n") 
 

Andreas

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu