0

I am writing log file system via fuse (FUSE-JNA). What I want to do is

  • log/insert current time in database table when user opens a file
  • and insert current time in database table when user closes a file

it is Just like web server logs.

For this, I thought implementing open() and release() methods would work:

public int open(final String path, final FileInfoWrapper info)
{
    System.out.println("open called: Path="+path); //replaced with code for inserting current time in database table 
    return 0;
}
@Override
public int release(final String path, final FileInfoWrapper info)
{
    System.out.println("release called: Path="+path);//replaced with code for inserting current time in database table
    return 0;
}

1-These methods are called when I open a file, that is fine

2-But when I just open the folder, These methods are also called for each file in the folder

How I would I distinguish between the above two. Because I just need to insert time when user open's a file and close time. Not when user open directory.

Please somebody help

1 Answers1

0

Use java.nio.File isFile() and isDirectory() to distinguish between the two.

WSBT
  • 33,033
  • 18
  • 128
  • 133
  • 1
    Welcome to SO and thanks for your answer. It has been flagged for review because it's rather brief. Could you expand upon it a little, and perhaps let the OP know how and why this helps. I can see that you're right, but I'm an experienced java developer, if the OP had the experience to understand why it's right, they'd have not had the question in the first place. – Software Engineer Jul 15 '14 at 19:56