Thread: creating files sequentially with a timer

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    72

    creating files sequentially with a timer

    Hi all,

    i receive some data from the network and i want to store this data in a files on disk sequentially each 8 hours, example:

    At the beginning i create the file file_00001 and all received data will go to this file, after 6 hours i create a new file file_00002 and send the file_00001 over the network and so on...

    If you have an idea on how to this feel free to answer me.
    Thanks for your help.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Well... we could tell you how to do it but you wouldn't learn much from that...

    Sit down and give it your best shot. If you run into trouble post your code and we'll see what we can do...

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Thanks for the reply, i have two problems :

    1. How to set a timer to 8 hours?
    2. How to stop writing in the precedent file (after timer expiration) and write data in a new one?

    Thanks.

  4. #4
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    1) That will depend on the platform.... For long time delays I would use the system time() function and check it about once every 10 seconds with a timer... Once the required number of seconds are gone by, I would invoke my "switch files" subroutine.

    2) When the time limit expires close your current file, ship it out on the net, then open a new file. If you're keeping copies use either a timestamp or sequence number in the filename...

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    can you post some sample code?

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by evariste View Post
    can you post some sample code?
    Well, that's kinda your job...

    Give it your best shot and when you get stuck, post what you've got and we'll see what we can do to help.

  7. #7
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    I have no idea on how to do that? i can create a file write the data on it but sequentially creating files with timer i really have no idea?

    Thanks.

  8. #8
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    1 Open file
    2 Start timer
    3 Write data
    4 Timer event -> close file -> send file
    5 goto 1

  9. #9
    Registered User
    Join Date
    Feb 2010
    Posts
    72
    Thanks "CommonTater" problem solved.

    Thanks for your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. has anyone used wiiYourself! ?
    By JCML in forum C++ Programming
    Replies: 0
    Last Post: 11-09-2010, 01:06 PM
  2. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 03:01 PM
  3. Creating text files
    By Crash1322 in forum C++ Programming
    Replies: 4
    Last Post: 12-15-2003, 09:55 PM
  4. Creating Files
    By Seb in forum C++ Programming
    Replies: 5
    Last Post: 06-15-2003, 08:11 PM
  5. creating make files
    By Unregistered in forum Linux Programming
    Replies: 4
    Last Post: 09-22-2001, 01:58 AM