Re: make dir in win32

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

C function "CreateDirectory" does that but it's not  in win32lib.

You define it like this:
    iCreateDirectory =

Maybe this function will do that, i don't know, i never tested it, it's not
mine:

global function create_directory(sequence x)
integer location, lastlocation, found, ok,errorCode
atom name
sequence directory
found = 0
lastlocation = 0
directory={0,0}
        x = x[8..length(x)]
        while 1 do
            location = find('/',x)
            if location = 0 and found = 0 then
                name = allocate_string(x)
                ok = c_func(iCreateDirectory,{name,0})
                if ok = 0 then
                    errorCode = c_func(iGetLastError,{})
                    if errorCode = 183 then
                    else
                    alertmsg("Can't create directory. Error code is " &
                        sprintf("%d", errorCode))
                    free(name)
                    directory = {0,0}
                    return directory
                    end if
                end if
                free(name)
                x = x & "\\"
                lastlocation = length(x)
                exit
            elsif location = 0 then
                exit
            end if
            x[location] = '\\'
            name = allocate_string(x[1..location-1])
            ok = c_func(iCreateDirectory,{name,0})
            if ok = 0 then
                errorCode = c_func(iGetLastError,{})
                if errorCode = 183 then
                else
                    alertmsg("Can't create directory. Error code is " &
                        sprintf("%d", errorCode))
                    free(name)
                    directory = {0,0}
                    return directory
                end if
            end if
            free(name)
            found = found + 1
            lastlocation = location
        end while
        if length(x) = lastlocation then
            directory[1] = x
            directory[2] = "default.htm"
            return directory
        end if
        directory[1] = x[1..lastlocation]
        directory[2] = x[lastlocation+1..length(x)]
        return directory
end function

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

Search



Quick Links

User menu

Not signed in.

Misc Menu