Find the answer to your Linux question:
Results 1 to 4 of 4
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/ ...
  1. #1
    Just Joined!
    Join Date
    Nov 2009
    Posts
    43

    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.

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    There's a set of functions called inotify that will do that for you. It's actually something that the kernel does as a service to processes that ask for it.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  3. #3
    Just Joined!
    Join Date
    Nov 2009
    Posts
    43
    Quote Originally Posted by hazel View Post
    There's a set of functions called inotify that will do that for you. It's actually something that the kernel does as a service to processes that ask for it.
    What is the difference between FAM and inotify ?

    Which one should I prefer ?

  4. #4
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    955
    FAM is a daemon that provides notify services for programs in general. I believe it uses inotify to get the information. If a program uses inotify directly, you don't need to have FAM running. I can't tell you which one is better because I've never used either. Hopefully someone else can take this thread over.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...