LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-16-2010, 07:27 AM   #1
aryan1
Member
 
Registered: Jul 2009
Posts: 50

Rep: Reputation: 16
Question detecting newly created folders/files on local file system


Hi All,

Using C++, I want to process sub-folders on my home folder sequentially each with a special naming format and containing some binary files in it:

Code:
1/
2/
3/
4/
5/
6/
...
Give above folders, I will process files in 1/ at first, 2/ at second, 3/ at third, and so on.

For some n/ folder, if I realize that n/ actually does not exist in local file system, I do not want to wait for it. Hence I will keep processing (n+1)/ folder, and so on.

However, when processing some (n+m)/ folder, previously not processed n/ folder may have been created on local file system. In this case, I do not want to miss processing it, but somehow detect its creation and process it. After processing n/ folder, I want to continue from (n+m+1)/.

How can I do this in Linux ?

What kind of architecture should I use ?

Thanks.
 
Old 04-16-2010, 07:33 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Bash or Perl script

use find to find out what all folders are created after you start the process.

Code:
man find
 
Old 04-16-2010, 07:36 AM   #3
aryan1
Member
 
Registered: Jul 2009
Posts: 50

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by PMP View Post
Bash or Perl script

use find to find out what all folders are created after you start the process.

Code:
man find
I will take a look at that.

What about newly created files ?
 
Old 04-16-2010, 07:44 AM   #4
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
You will get the answer
look the man page of find
 
Old 04-18-2010, 02:59 PM   #5
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
You could just store the index of the folders you originally skipped in an array and then after processing each folder, scan the array for any folders you have missed and see if they now exist. Once you have processed them, remove them from the array. Your choice of language here is up to you but as suggested above, bash and perl are prime candidates.
 
1 members found this post helpful.
Old 04-18-2010, 03:09 PM   #6
librano
Member
 
Registered: Jul 2004
Location: Here, there and everywhere.
Distribution: Arch+KDE, Linux Mint Fluxbox CE
Posts: 163

Rep: Reputation: 31
I would suggest looking at inotify as well. If you are using Bash or Python, implementation is easy... not so sure about C++. Anyway, it is very lightweight and you can configure it to check for files, folders, whether they are created, opened, modified, deleted, etc. It is a great tool.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't cd into created folders in Documents Folder either on Desktop or in File System bparkerson04 Linux - Newbie 2 01-20-2009 12:44 AM
is there a way to check for newly created files without having to access the mount ignarus Linux - General 3 03-05-2008 04:01 AM
FTP, newly created files permission georgiozoze Linux - Newbie 2 09-16-2006 08:47 PM
permissions for newly created files dialbat Linux - General 2 10-04-2004 02:58 PM
snort error: newly created file is older than distributed files! rufassa Linux - Security 1 11-07-2003 08:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration