Login Form






Lost Password?
No account yet? Register

Syndicate

Newsflash

 At the interview on the job did not provide first hand to a future employer (a man) just waited until he can. Do you make a faux pas?
 
FireBoard
Welcome, Guest
Please Login or Register.    Lost Password?
good time max How to get file count under a directory? (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: good time max How to get file count under a directory?
#36015
rockdale (Visitor)
Click here to see the profile of this user
Birthdate:
good time max How to get file count under a directory?  
Hi, I have an application which writes log files out. If then log file size is great than let's say 1M, the application will create a new log file with sequence number. the log file format likes mylogfile_mmddyy_1.txt, mylogfile_mmddyy_2.txt. ....without upper limit. Now the problem is if my application get restarted, I need to know what is the largest sequence number  of my log file. I am thinking in a loop from 1 to like 100000, check if the file exist, if it does not , then I get the max sequence number I need. But this method looks very awkward. Is there another way to do this(get the max number for a series of similar files)? My applicaiton is running on windows platform but did not using MFC function very much. Thanks in advance -Rockdale
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#36016
Victor Bazarov (Visitor)
Click here to see the profile of this user
Birthdate:
good time max How to get file count under a directory?  
My applicaiton is running on windows platform but did not using MFC function very much. Try posting to a relevant newsgroup from 'microsoft.public.*' hierarchy where Windows platform-specific stuff is discussed. V
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#36017
Sjouke Burry (Visitor)
Click here to see the profile of this user
Birthdate:
good time max How to get file count under a directory?  
Hi, I have an application which writes log files out. If then log file size is great than let's say 1M, the application will create a new log file with sequence number. the log file format likes mylogfile_mmddyy_1.txt, mylogfile_mmddyy_2.txt. ....without upper limit. Now the problem is if my application get restarted, I need to know what is the largest sequence number  of my log file. I am thinking in a loop from 1 to like 100000, check if the file exist, if it does not , then I get the max sequence number I need. But this method looks very awkward. Is there another way to do this(get the max number for a series of similar files)? My applicaiton is running on windows platform but did not using MFC function very much. Thanks in advance -Rockdale Step 100 at a time to go past the last one, then step 1 at a time trough the last partial block.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#36018
mzdude (Visitor)
Click here to see the profile of this user
Birthdate:
good time max How to get file count under a directory?  
I have an application which writes log files out. If then log file size is great than let's say 1M, the application will create a new log file with sequence number. the log file format likes mylogfile_mmddyy_1.txt, mylogfile_mmddyy_2.txt. ....without upper limit. Now the problem is if my application get restarted, I need to know what is the largest sequence number  of my log file. I am thinking in a loop from 1 to like 100000, check if the file exist, if it does not , then I get the max sequence number I need. But this method looks very awkward. Is there another way to do this(get the max number for a series of similar files)? My applicaiton is running on windows platform but did not using MFC function very much. Well for starters you can create simple text file to contain the next numeric number in your log sequence. Every time you increment your log file number, update the text file. Then it's simply a matter of opening and reading the number. The which Operating System (windows, linux, ..) or library (mfc, boost, ...) you are using is irrelevant. NextNumber.txt   1234
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#36019
Juha Nieminen (Visitor)
Click here to see the profile of this user
Birthdate:
good time max How to get file count under a directory?  
Is there another way to do this(get the max number for a series of similar files)? http://www.boost.org/doc/libs/1_40_0/libs/filesystem/doc/index.htm
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#36020
Marcel Müller (Visitor)
Click here to see the profile of this user
Birthdate:
good time max How to get file count under a directory?  
My applicaiton is running on windows platform but did not using MFC function very much. That makes no difference here. Using rotating logs with a fixed time slice is straight forward to implement, although in case of application restarts. You could use a simple and fast hash function on the time stamp, that controls log file switches. Every time the hash changes a virtual method that switches the log could be invoked. Only his method implements the full rendering of the file name scheme. This makes it very easy and with good performance to implement different cycle times, e.g once per week, once per day and once per hour. And if you are even smarter you could add a functionality that cleans up old log automatically once they exceed a configured age. This prevents from the common issue of full volumes. Again a fixed relation between the file name and the content is helpful. All you have to do is to calculate the file name that corresponds to now minus a configured period and delete all files in the folder which names compare less to this name and which match the pattern of your logfiles, e.g. mylogfile_*.txt. Neither you have to touch their content nor you have to parse the names. Unfortunately this will always be O(n), so it should not be invoked too often (e.g. once a day). Marcel
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Who's Online

We have 67 guests online

Fred Dust - divorced after 2 month of marriage

And it all could be so beautifu... bathroomfurniture.wordpress. furniture.blogsboom.com Body Detox lA little over two months ago, lucky singer Limp Bizkit, Fred Durst, announced to the world on a blog that he married his girlfriend, Esther Nazarov. Relationship had to be perfect, couple well-chosen and proven over the years. Unfortunately, only a few weeks after the intimate ceremony in Las Vegas Durst once wrote in an online diary: I would like to asbestos melbourne india phone card Best reviews blog inform all concerned that Esther and I decided that it was time to go separate ways in life. Thank you to everyone who supported us. I am grateful for the support and warm words. Very. I can also say that they both hold up well and parting culturally, in a positive atmosphere.

Pamela Anderson: I'm not a bancrupt!

A few days ago we wrote used cars accommodation wroclaw Steroids about the debt, which has caused the Pamela Anderson, as every year, changing the decor of his house. The owner of the famous zgranulowanych breast wished costly and sophisticated alterations, and when the contractor sent its bill Ceased to answer calls. Currently, debt is more than 1.2 million dollars, but Pam used cars property costa del sol anglais pour debutant insists that ... There are no debts. I am completely financially stable, and I thank all those who contested the recent media reports - wrote in a statement issued yesterday Anderson. It is true that I am still in the course of discussions with some of the subcontractors working on my house. But that's because after paying millions of dollars for its construction still get a wrong call for payment of accounts. My lawyers check out how the work asia photography kate moss automobiles.money4car.co.uk has been done and whether professionals actually have the right to require such enormous sums. Where appropriate, it will pay, if not - it does not. I am only sorry that one of the performers went with the whole affair to the press.