1. Help request for Standard Library Project

I have added file operation routines,
now I need the Linux version of copy file, mkdir and rmdir.

For win32 it's done.
(Actually I don't care about dos32 version :P)

One more thing, which hash library do you think is the most reliable
and simple enough for inclusion?

I need your feedback for this project, (which now can be dled from
http://www.rapideuphoria.com/stdliba.e) such as which routines are
missing, which functions are not useful enough for inclusion, how to
optimize, etc.

Please give feedback, thank you!


object xGetTickCount, xSleep, xCopyFile, xMoveFile, xDeleteFile,
xCreateDirectory, xRemoveDirectory
if platform() = WIN32 then
xGetTickCount     = define_c_func(open_dll("kernel32"), "GetTickCount", {},
    C_LONG)
    xSleep            = define_c_proc(open_dll("kernel32"), "Sleep", {C_ULONG})
xCopyFile         = define_c_func(open_dll("kernel32"), "CopyFileA",
    {C_POINTER, C_POINTER, C_LONG}, C_LONG)
xMoveFile         = define_c_func(open_dll("kernel32"), "MoveFileA",
    {C_POINTER, C_POINTER}, C_LONG)
xDeleteFile       = define_c_func(open_dll("kernel32"), "DeleteFileA",
    {C_POINTER}, C_LONG)
xCreateDirectory  = define_c_func(open_dll("kernel32"), "CreateDirectoryA",
    {C_POINTER, C_POINTER}, C_LONG)
xRemoveDirectory  = define_c_func(open_dll("kernel32"), "RemoveDirectoryA",
    {C_POINTER}, C_LONG)
elsif platform() = LINUX then
xMoveFile         = define_c_func(open_dll(""), "rename", {C_POINTER,
    C_POINTER}, C_LONG)
xDeleteFile       = define_c_func(open_dll(""), "remove", {C_POINTER},
    C_LONG)
end if

---------------------------------------------------------------------
--# File Operations
---------------------------------------------------------------------

-- copy_file(string src, string dest, bool overwrite)
-- copies a file from /src to /dest. 
-- If /overwrite is true, if /dest file already exists, 
-- the function overwrites the existing file and succeeds.
-- Returns false if failed, true if succeeded.
global function copy_file(sequence src, sequence dest, atom overwrite)
atom psrc, pdest, ret
    psrc = allocate_string(src)
    pdest = allocate_string(dest)
    ret = c_func(xCopyFile, {psrc, pdest, not overwrite})
    free(pdest)
    free(psrc)
    return ret
end function

-- move_file(string src, string dest)
-- moves/renames a file from /src to /dest. 
-- Returns false if failed, true if succeeded.
global function move_file(sequence src, sequence dest)
atom psrc, pdest, ret
    psrc = allocate_string(src)
    pdest = allocate_string(dest)
    ret = c_func(xMoveFile, {psrc, pdest})
    if platform() = LINUX then ret = not ret end if
    free(pdest)
    free(psrc)
    return ret
end function

-- delete_file(string filename)
-- deletes a file named /filename
-- Returns false if failed, true if succeeded.
global function delete_file(sequence filename)
atom pfilename, ret
    pfilename = allocate_string(filename)
    ret = c_func(xDeleteFile, {pfilename})
    if platform() = LINUX then ret = not ret end if
    free(pfilename)
    return ret
end function

-- create_directory(string name)
-- creates a directory named /name
-- Returns false if failed, true if succeeded.
global function create_directory(sequence name)
atom pname, ret
    pname = allocate_string(name)
    ret = c_func(xCreateDirectory, {pname, 0})
    free(pname)
    return ret
end function

-- remove_directory(string name)
-- removes a directory named /name
-- Returns false if failed, true if succeeded.
global function remove_directory(sequence name)
atom pname, ret
    pname = allocate_string(name)
    ret = c_func(xRemoveDirectory, {pname})
    free(pname)
    return ret
end function

new topic     » topic index » view message » categorize

2. Re: Help request for Standard Library Project

aku saya wrote:

> I have added file operation routines,

<snip>

The term "Standard (Euphoria) Library Project" is already used by a
different project. Do you actually think it's good style to use this
name for your project now?

Regards,
   Juergen

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu