473,669 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Log file deletion?

I am new to c++. Here is my problem. When my application runs it
creates a log file for that day containing application specific
information. The file format is CCSI_2006_51.lo g with 2006 being the
year and 51 being the days since Jan 1st. If we run this application
again on the same day it will append to the file already created
earlier. Though this application might not run everyday. So we could
have CCSI_2006_48.lo g and then CCSI_2006_51.lo g. I need to keep all log
files from 40 days ago to the present. There could be a total of 40 log
files if the application was indeed ran everyday for 40 day. Anything
created before 40 days ago has to be deleted.

Im think of the approach of a loop that checks the creation date of all
files ending in .log in a given directory and then deleting those that
have a date before presentDay minus 40. I have no idea how to do this
in c++ and my reference book doesn't have anything about this. I know
how to delete a file using the remove() method but how do I go through
every file ending in .log in a directory in c++ and how do I get the
creation date from the file into c++? Oh, the platform is linux.

Any help would be greatly appreciated.

Thanks in advance

Feb 21 '06 #1
1 2173
subaruwrx88011 wrote:
[..] I know
how to delete a file using the remove() method but how do I go through
every file ending in .log in a directory in c++ and how do I get the
creation date from the file into c++? Oh, the platform is linux.


There are no platform-independent ways [yet] in C++ to enumerate all files
whose name is of a particular pattern. You need to use platform-specific
means to do that. Since you use Linux, ask in comp.os.linux.d evelopment.*
newsgroups.

V
--
Please remove capital As from my address when replying by mail
Feb 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8799
by: Ryan | last post by:
I have a table in my database on SQL Server which holds a file name that refers to a file that is stored on the server. I would like to create a trigger to delete this file from the server if the row in the table is deleted. I have been trying to use this command in a trigger (<filename> is the name and path of the file): xp_cmdshell "delete <filename>" If some one could please help I would appreciate it very much. I would love a...
2
1837
by: Justin | last post by:
Hi all, Does anybody know a way, in VB.Net, I can discover the file locks on a file on the local machine. I have an application which needs to delete specific files, but I would like to verify in advance whether or not a particular deletion will succeed. Due to other pre-deletion actions, I cannot attempt the deletion and catch the exception if it fails. Thanks in advance
6
5291
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not report any error while writing to the open file handle. On Windows, file shows-up again in explorer and automatically deleted finally when program ends. On Unix, same thing happens if file is on nfs mounted drive, but in this case, actual file is...
7
1254
by: Diggler | last post by:
I have a web application that allows a user to manage files on the server. On the page is a counter that tells them how many files are in their folder. When you delete a file from the folder using ASP.NET, it seems to send a command off to delete the file and keeps processing the page... the page reloads, but the file count of the folder doesn't change because it seems that the page rendering is faster than the file deletion. Is there...
2
15988
by: kelly | last post by:
Hi, I don't have a code to show you, what I need are references or algorithms so that I'm in a right track. By the way, thanks for introducing me the array or arrays. Now I can continue my script. Now I want to delete a line from a file. Line being the strings I got/saved to/from array of arrays.
3
1675
by: A_Republican | last post by:
I am interested in writing my own secure file deletion program. I want to be able to read and write to my hard drive directly. My application will seach my hard drive for all locations marked for deletion and then replace it with "x" or something that securely removes previoius data. My question is what objects, API calls, etc, etc do I use to read and write directly to the hard drive? -- Regards, Shaun Goldston
0
2179
by: ferdz3001 | last post by:
Hi, I have read some of the forums regarding deletion of log files. Just to get more information before I perform the deletion of log files. These are the steps I got: 1. db2 get db cfg <DBSID> 2. search for the "first active log file", then subtract 1 from it. For example i got S0000745.LOG. Subtract 1, that's S0000744.LOG 3. db2 prune logfile prior to S0000744.LOG What is the difference if I simply command the "rm -r <filename>"? I...
1
2105
roswara
by: roswara | last post by:
Dear all, Currently, I am working on a project to make a web-based application using ASP 2.0 and C#. This application will ask user to input for an excel file which has graphs in it. Then the application will grab the graph as image file, and this image will be displayed as thumbnail in the page. Is it possible to accomplish this feature? If it is possible, would you please tell me how? And if it is not possible, why?
4
25859
by: BibhuAshish | last post by:
Hi, I wanted to delete a line from xml file which i did it. But after deletion of that line there is a blank space. Again if i am adding another line by using java that blank line remains as usual. My xml file is ::::::: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <config> <employee id = "1" name = "aa" /> <employee id = "2" name = "bb" />
6
4207
by: Bill H | last post by:
I am wondering if this is possible. I have a file that is accessed by multiple users and keeps track of activity (the file is polled by flash every 2 seconds). As users leave, the flash program tells the php program to remove them from the activity file, and as users access this activity file, users who have timed out (haven't been heard from in 60 seconds) are removed. Using a combination of flock, microsecond sleeps, loops and the flash...
0
8383
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8809
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.