progressbar

This is a discussion on progressbar within the C Programming forums, part of the General Programming Boards category; hi all i would like discuss about progressbar. while am copying a file or folder.. to other directory or to ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    136

    progressbar

    hi all
    i would like discuss about progressbar.

    while am copying a file or folder..
    to other directory or to other folder...
    a window will appearing it showing progressbar..
    here it showing file size and delay time..

    how much it is copying and how much it is left.. like this..
    i would like to use this..
    i am copying a file to other folder..
    using "cp -p", but it is not showing this progressbar window..
    i would like to show this window..

    can you please help me

    thnak you in advance

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    do a "man cp", and you'll see it's not supposed to show a progress bar

    Quote Originally Posted by man cp
    -P, --no-dereference
    never follow symbolic links

    -p same as --preserve=mode,ownership,timestamps
    This isn't strictly C related and should have gone in the Linux board. If you want it 'terminal based' then use a library like nCurses, or if you want it GUI based use GTK+ or Qt (or something else). As do get the status on just how much you've read / ETA, that is for you to find out, DO SOME RESEARCH !

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Well if you were copying a folder, you would first count the files in the folder.
    Then in a loop, copy each file individually and then advance the progress bar by 100/n of a step, assuming your progress bar was calibrated in percentage terms.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    136
    Quote Originally Posted by Salem View Post
    Well if you were copying a folder, you would first count the files in the folder.
    Then in a loop, copy each file individually and then advance the progress bar by 100/n of a step, assuming your progress bar was calibrated in percentage terms.
    hi
    assuming that .i am copying only one file.
    it may be the size of 1k,10k,99k,1M,999M and 3G
    how can i derive the pulses of progressbar?.

    and what is 100/n?

    i am storing the size in "char".
    how can i divide this..

    please help me

    thank you in advance

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by munna_dude View Post
    hi
    assuming that .i am copying only one file.
    it may be the size of 1k,10k,99k,1M,999M and 3G
    how can i derive the pulses of progressbar?.

    and what is 100/n?

    i am storing the size in "char".
    how can i divide this..

    please help me

    thank you in advance
    I would change your size variable to something much larger than a char. I'm thinking your OS will have a default variable type for use with file sizes, and your compiler will support that type, also.

    The 100/n refers to how often you might want your progress bar to show progress, as the file (or files) is (are) being moved, I believe. I think of it as 1/100th or 1%.

    In your copy loop:
    pseudo code:
    Code:
    i = 0
    while there are more bytes to be copied
       i += 10
       fgets() or fread() say 512 bytes, if available
       and write it to the new file
       fprintf() or fwrite()
       if( bytes copied * 100 > i * total bytes to be copied)
           print another progress char (ASCII char 176, 177, 178 in text mode, recommended). 
    loop back
    It looks nice if the progress bar has at least 10 char's in it's width, and no more than 30.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    136
    thank you i did this progressbar pulse...
    like (100/filesize in bytes) and am convering file size in to float value using atof()
    but for 1.2M(1221948 bytes)
    100/1221948=====
    taking progressbar is very slow...

    and here how can i know estimated time to copy perticular size of a file...
    remaing time to copy a file....

    can you please help me

    thank you in advance

  7. #7
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Well work out how many bytes your doing a second (on average)...

    eg, for arguments sake, say you copy 10,000 bytes in 5 seconds, that's 2000 bytes/sec. And if you've got say 50,000 bytes to go thats an ETA of 50,000 / 2000 seconds

  8. #8
    Registered User
    Join Date
    Dec 2006
    Posts
    136
    Quote Originally Posted by zacs7 View Post
    Well work out how many bytes your doing a second (on average)...

    eg, for arguments sake, say you copy 10,000 bytes in 5 seconds, that's 2000 bytes/sec. And if you've got say 50,000 bytes to go thats an ETA of 50,000 / 2000 seconds
    sorry for this..
    i cant understand..
    so, first i ve to copy a file and and see the time..
    i did copy paste.
    with in 7 seconds i copied 100611257 bytes.

    can you please explain it clearly..
    thank you in advance

  9. #9
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Okay,
    * Equate how many bytes you're currently copying a second (preferably dynamically)
    * Work out how many bytes you have to go, (TotalSize - BytesCopied)
    * Then you can work out how long it's going to take to copy the remaining bytes, ((TotalSize - BytesCopied) / BytesPerSecond) seconds

    You seem to do a lot of posting with little or no research and it's only landing you in strife

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. progressBar
    By Coding in forum C# Programming
    Replies: 5
    Last Post: 02-23-2008, 07:52 AM
  2. ProgressBar
    By Leite33 in forum Windows Programming
    Replies: 1
    Last Post: 01-15-2007, 08:21 AM
  3. Refresh ProgressBar
    By Dimeslime in forum C# Programming
    Replies: 2
    Last Post: 10-22-2003, 03:47 PM
  4. Progressbar as Part of Statusbar :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-26-2002, 09:59 AM
  5. More PROGRESSBAR help!(SIMPLE!)
    By SyntaxBubble in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2001, 03:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21