Results 1 to 10 of 20

Thread: asynchronous file operations

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Member DirectuX's Avatar
    Join Date
    Oct 2018
    Location
    France
    Posts
    417
    Rep Power
    55
    Quote Originally Posted by ErosOlmi View Post
    Updated thinBasic 1.11.3 at https://www.thinbasic.biz/projects/t...c_1.11.3.0.zip

    Added FILE_CopyEX function (not yet documented) that partially wrap CopyFileExA https://docs.microsoft.com/en-us/win...se-copyfileexa

    How to use?
    Check example in \thinBasic\SampleScripts\File\File_CopyEX.tbasic reported here below.
    Copy one file into destination and automatically call a "CopyProgressRoutine" callback function during copy execution in order to have the option to progress some info or cancel operation.
    IMPORTANT "CopyProgressRoutine" callback function can have any name but MUST EXACTLY be defined like in the example (otherwise script will GPF)

    I've tested with files larger up to 140MB as seems very fast.
    I tested it. Yes, fast for regular files.
    I tested it for GB files too. Works.

    From documentation
    dwCopyFlags
    Flags that specify how the file is to be copied.
    Value Meaning
    COPY_FILE_NO_BUFFERING
    0x00001000
    The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers.


    Quote Originally Posted by ErosOlmi View Post
    Data chunk size cannot be controlled.
    That would be for optimization against sector size. (Former I've seen noticeable speed improvement when adjusting this for RAID disks; today I've no RAID)

    Quote Originally Posted by ErosOlmi View Post
    If I'm on the right track I will wrap CopyFileExW and possibly add more options.
    Let me know if it what you needed.
    Ah ! I've missed something. I thought that with callbacks coding style, script would be able to continue while the filesystem operations are processed, and be notified regularly on process progress. In fact, the script waits for the copy to end.

    Quote Originally Posted by DirectuX View Post
    thinBasic\SampleScripts\UI\Power\Power_Messages.tBasic is a sample that can detect power status changes via callback management.
    I'm in search of such behaviour for complete filesystem interaction.
    As a start I studied the file copy feature:
    Both FILE_Copy and FILE_ShellCopy are synchronous functions. None can expose the copy progression to the script.
    So... having a progression feedback, we are at half way.
    Quote Originally Posted by DirectuX View Post
    Before moving in any direction, I would like to ask (...)
    I think I mislead myself with ideas like DIALOG SHOW MODELESS instruction and callbacks. That is one reason I started questioning
    Now, I foresee even more the difficulty to have asynchronous file operation.

    Quote Originally Posted by ErosOlmi View Post
    Let me know if it what you needed.
    Except the non script-blocking disk-operations that is essential.




    For information. My project is not alpha ready but on right track.
    Roughly : I have:
    1 filesystem(FS) unit
    1 DB unit
    1 UI unit (no started yet)

    user can work offline to queue operations (disks and shares can be offline), by interacting on DB through UI.
    script tries to execute FS operations as soon as possible ( rename, copie, move, delete) while not blocking user work
    script maintain db up to date. (not yet explored)

    thinking...

    maybe I should split the project in two scripts ? (I'd rather not)

    I want to start simple (manual db update) and add feature on progress.

    Features for alpha :
    manual db update
    display (2 panes) disks folder tree + files + duplicates
    basic file operations




    PS : not going into multi-threading like xLeaves's LzBot , is this concept possible in thinBasic ? (this is single thread)
    Last edited by DirectuX; 06-02-2020 at 18:17.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Similar Threads

  1. Demonstration of matrix operations
    By Petr Schreiber in forum TBGL Tutorials
    Replies: 4
    Last Post: 30-03-2009, 16:24

Members who have read this thread: 1

Tags for this Thread

Posting Permissions

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