Integrity check in C++

Dear pros:

I have two similar issues I would like to ask about, and I'd be

grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level

C)? I know there’s a software called h5check, but I need a function
to do that, not a software. In my application, it’s not an option to
execute h5check from my system.

2- How can I do a quick check in C/C++ to see whether the file is

being written/modified/open for write? I looked in
this link
which discusses metadata, but there doesn’t seem to
be a clear way through the C/C++ interface for me a to read the
first two bits that give me that information. Could you please help
with that with a simple example?

All the best,

Samer

Hello Samer,

Is this function

https://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-GetIntent

useful for your #2 issue?

Thanks,

?Binh-Minh

···

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Samer Afach <webmaster@afach.de>
Sent: Saturday, July 18, 2015 10:23 AM
To: hdf-forum@lists.hdfgroup.org
Subject: [Hdf-forum] Integrity check in C++

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I know there's a software called h5check, but I need a function to do that, not a software. In my application, it's not an option to execute h5check from my system.

2- How can I do a quick check in C/C++ to see whether the file is being written/modified/open for write? I looked in this link<https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which discusses metadata, but there doesn't seem to be a clear way through the C/C++ interface for me a to read the first two bits that give me that information. Could you please help with that with a simple example?

All the best,
Samer

Dear Binh:

Thank you very much for your quick response. I'm not sure though I

understand how this will help. Should I assume that if the file was
open as read-only, that this definitely means that the file is being
access by some other writing authority and thus it’s incomplete?

Thanks.

All the best,

Sam
···

On 18.07.2015 17:17, Binh-Minh Ribler
wrote:

Hello Samer,

Is this function

https://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-GetIntent

useful for your #2 issue?

Thanks,

​Binh-Minh


From:
Hdf-forum on
behalf of Samer Afach Saturday, July 18, 2015 10:23 AM
[Hdf-forum] Integrity check in C++

Dear pros:

        I have two similar issues I would like to ask about, and I'd

be grateful if you could help me:

        1- How can I check HDF5 file integrity in C/C++ (I prefer

low level C)? I know there’s a software called h5check, but
I need a function to do that, not a software. In my
application, it’s not an option to execute h5check from my
system.

        2- How can I do a quick check in C/C++ to see whether the

file is being written/modified/open for write? I looked
in
this link
which discusses metadata, but there doesn’t
seem to be a clear way through the C/C++ interface for me a
to read the first two bits that give me that information.
Could you please help with that with a simple example?

        All the best,

        Samer


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

hdf-forum-bounces@lists.hdfgroup.orgwebmaster@afach.de
Sent:
**To:**hdf-forum@lists.hdfgroup.org
**Subject:**Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

Hi Samer,

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I know there's a software called h5check, but I need a function to do that, not a software. In my application, it's not an option to execute h5check from my system.

Is there any objection against you taking the source code of h5check, rename the main function to h5check_main() and then call it as C function from your code?

2- How can I do a quick check in C/C++ to see whether the file is being written/modified/open for write? I looked in this link <https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which discusses metadata, but there doesn't seem to be a clear way through the C/C++ interface for me a to read the first two bits that give me that information. Could you please help with that with a simple example?

This sounds as if you want to know what the HDF5 library is currently doing with a file? Well what you could do is to modify the virtual file driver that you want to use, and let it keep track of that happens with the file. It's the VFD that does the actual writing of a file content, so you can trace its write() call to keep track what exactly happens when. It's some effort of course.

Cheers,
            Werner

···

On 18.07.2015 16:23, Samer Afach wrote:

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

Hi Samer,

I misunderstood your question. I thought you were interested in whether the file was opened for write.

?Binh-Minh

···

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org> on behalf of Samer Afach <webmaster@afach.de>
Sent: Saturday, July 18, 2015 11:28 AM
To: HDF Users Discussion List
Subject: Re: [Hdf-forum] Integrity check in C++

Dear Binh:

Thank you very much for your quick response. I'm not sure though I understand how this will help. Should I assume that if the file was open as read-only, that this definitely means that the file is being access by some other writing authority and thus it's incomplete?

Thanks.

All the best,
Sam

On 18.07.2015 17:17, Binh-Minh Ribler wrote:

Hello Samer,

Is this function

https://www.hdfgroup.org/HDF5/doc/RM/RM_H5F.html#File-GetIntent

useful for your #2 issue?

Thanks,

?Binh-Minh

________________________________
From: Hdf-forum <hdf-forum-bounces@lists.hdfgroup.org><mailto:hdf-forum-bounces@lists.hdfgroup.org> on behalf of Samer Afach <webmaster@afach.de><mailto:webmaster@afach.de>
Sent: Saturday, July 18, 2015 10:23 AM
To: hdf-forum@lists.hdfgroup.org<mailto:hdf-forum@lists.hdfgroup.org>
Subject: [Hdf-forum] Integrity check in C++

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I know there's a software called h5check, but I need a function to do that, not a software. In my application, it's not an option to execute h5check from my system.

2- How can I do a quick check in C/C++ to see whether the file is being written/modified/open for write? I looked in this link<https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which discusses metadata, but there doesn't seem to be a clear way through the C/C++ interface for me a to read the first two bits that give me that information. Could you please help with that with a simple example?

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org<mailto:Hdf-forum@lists.hdfgroup.org>
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Dear Werner:

Thank you for your response and your time.

I tried modifying the source code of h5check, but it's very

complicated and returns strings instead of error codes. Besides, I
tried to compile it by including the three files in the main c file
and it gave errors that don’t seem to be easily trackable. It’ll
take me lots of time to prepare something reliable out of it with
full testing. I wonder why the hdf group didn’t implement such a
functionality in low language, I thought it exists and I can’t find
it. :frowning:

About my second question, apparently I wasn't clear on what I really

need and I was misunderstood. What I need is to check whether the
file I want to read is being accessed by some other program. My
problem is that the file I wanna deal with is being written by some
other program, and I want to initiate an upload after it’s done
writing. So I would like to check whether the other program is
finished writing and closed it before I send it to my upload queue.

All the best,

Samer
···

On 18.07.2015 23:11, Werner Benger
wrote:

Hi Samer,

  Is there any objection against you taking the source code of

h5check, rename the main function to h5check_main() and then call
it as C function from your code?
This sounds as if you want to know what the HDF5 library is
currently doing with a file? Well what you could do is to modify
the virtual file driver that you want to use, and let it keep
track of that happens with the file. It’s the VFD that does the
actual writing of a file content, so you can trace its write()
call to keep track what exactly happens when. It’s some effort of
course.
Cheers,
���������� Werner

    On 18.07.2015 16:23, Samer Afach

wrote:

Dear pros:

    I have two similar issues I would like to ask about, and I'd be

grateful if you could help me:

    1- How can I check HDF5 file integrity in C/C++ (I prefer low

level C)? I know there’s a software called h5check, but I need a
function to do that, not a software. In my application, it’s not
an option to execute h5check from my system.

    2-

How can I do a quick check in C/C++ to see whether the file is
being written/modified/open for write? I looked [

      in

this link](https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData) which discusses metadata, but there doesn’t seem
to be a clear way through the C/C++ interface for me a to read
the first two bits that give me that information. Could you
please help with that with a simple example?

    All

the best,

    Samer


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

Hi Samer,

  do you have full source code access to both programs, the one writing the file and the one uploading it?

If so, would adding some file locking mechanism ( https://en.wikipedia.org/wiki/File_locking ) help your case?

Cheers,
               Werner

···

On 19.07.2015 02:50, Samer Afach wrote:

Dear Werner:

Thank you for your response and your time.

I tried modifying the source code of h5check, but it's very complicated and returns strings instead of error codes. Besides, I tried to compile it by including the three files in the main c file and it gave errors that don't seem to be easily trackable. It'll take me lots of time to prepare something reliable out of it with full testing. I wonder why the hdf group didn't implement such a functionality in low language, I thought it exists and I can't find it. :frowning:

About my second question, apparently I wasn't clear on what I really need and I was misunderstood. What I need is to check whether the file I want to read is being accessed by some other program. My problem is that the file I wanna deal with is being written by some other program, and I want to initiate an upload after it's done writing. So I would like to check whether the other program is finished writing and closed it before I send it to my upload queue.

All the best,
Samer

On 18.07.2015 23:11, Werner Benger wrote:

Hi Samer,

On 18.07.2015 16:23, Samer Afach wrote:

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I know there's a software called h5check, but I need a function to do that, not a software. In my application, it's not an option to execute h5check from my system.

Is there any objection against you taking the source code of h5check, rename the main function to h5check_main() and then call it as C function from your code?

2- How can I do a quick check in C/C++ to see whether the file is being written/modified/open for write? I looked in this link <https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which discusses metadata, but there doesn't seem to be a clear way through the C/C++ interface for me a to read the first two bits that give me that information. Could you please help with that with a simple example?

This sounds as if you want to know what the HDF5 library is currently doing with a file? Well what you could do is to modify the virtual file driver that you want to use, and let it keep track of that happens with the file. It's the VFD that does the actual writing of a file content, so you can trace its write() call to keep track what exactly happens when. It's some effort of course.

Cheers,
           Werner

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

Dear Werner:

Unfortunately I don't have the source of the writing program. It

could be anything actually; labview, C, C++, etc… . I’m working on
a collaborative program for collecting data, and my software is
supposed to upload the data to the main storage server for backup
and data analysis. Everyone is free to use any tools they want for
data acquisition.

Is there any solution to my problem that doesn't involve me having

authority on the writing program? Currently I’m using a method that
I invented, where I measure the size of the file multiple times, and
if the size doesn’t change for some time, then that decide that the
file isn’t being written… that’s the only way I could come up
with, but this has nothing to do with HDF5.

All the best,

Samer
···

On 19.07.2015 12:23, Werner Benger
wrote:

Hi Samer,

  �do you have full source code access to both programs, the one

writing the file and the one uploading it?

  If so, would adding some file locking mechanism (� ) help your case?

Cheers,
������������� Werner

https://en.wikipedia.org/wiki/File_locking

    On 19.07.2015 02:50, Samer Afach

wrote:

Dear Werner:

    Thank you for your response and your time.



    I tried modifying the source code of h5check, but it's very

complicated and returns strings instead of error codes. Besides,
I tried to compile it by including the three files in the main c
file and it gave errors that don’t seem to be easily trackable.
It’ll take me lots of time to prepare something reliable out of
it with full testing. I wonder why the hdf group didn’t
implement such a functionality in low language, I thought it
exists and I can’t find it. :frowning:

    About my second question, apparently I wasn't clear on what I

really need and I was misunderstood. What I need is to check
whether the file I want to read is being accessed by some other
program. My problem is that the file I wanna deal with is being
written by some other program, and I want to initiate an upload
after it’s done writing. So I would like to check whether the
other program is finished writing and closed it before I send it
to my upload queue.

    All the best,

    Samer
      On 18.07.2015 23:11, Werner Benger

wrote:

Hi Samer,

      Is there any objection against you taking the source code of

h5check, rename the main function to h5check_main() and then
call it as C function from your code?
This sounds as if you want to know what the HDF5 library is
currently doing with a file? Well what you could do is to
modify the virtual file driver that you want to use, and let
it keep track of that happens with the file. It’s the VFD that
does the actual writing of a file content, so you can trace
its write() call to keep track what exactly happens when. It’s
some effort of course.
Cheers,
���������� Werner
On 18.07.2015 16:23, Samer Afach
wrote:

Dear pros:

        I have two similar issues I would like to ask about, and I'd

be grateful if you could help me:

        1- How can I check HDF5 file integrity in C/C++ (I prefer

low level C)? I know there’s a software called h5check, but
I need a function to do that, not a software. In my
application, it’s not an option to execute h5check from my
system.

        2- How can I do a quick check in C/C++ to see whether the

file is being written/modified/open for write? I looked [

          in

this link](https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData) which discusses metadata, but there doesn’t
seem to be a clear way through the C/C++ interface for me a
to read the first two bits that give me that information.
Could you please help with that with a simple example?

All the best,

        Samer


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

Hi Samer,

  if those applications are linking dynamically with HDF5, you could interface there by providing a "patched" version of HDF5 that is binary compatible, but still performs some file locking, possibly via a modified VFD.

Just checking the file sizes won't be a sure check, in particular it would not work for and application that does not append data but modifies existing ones. You should be able to check the "last modified" date on the file as well, and if the HDF5 file cannot be opened by another application, then it's either corrupted or still open and data written to it.

It should also be possible to find out which process has file handles to a specific file open, both Linux and Windows seem to allow that, just in an OS-specific way:

It may require your program to run under admin rights though.

Cheers,
           Werner

···

On 19.07.2015 12:32, Samer Afach wrote:

Dear Werner:

Unfortunately I don't have the source of the writing program. It could be anything actually; labview, C, C++, etc... . I'm working on a collaborative program for collecting data, and my software is supposed to upload the data to the main storage server for backup and data analysis. Everyone is free to use any tools they want for data acquisition.

Is there any solution to my problem that doesn't involve me having authority on the writing program? Currently I'm using a method that I invented, where I measure the size of the file multiple times, and if the size doesn't change for some time, then that decide that the file isn't being written... that's the only way I could come up with, but this has nothing to do with HDF5.

All the best,
Samer

On 19.07.2015 12:23, Werner Benger wrote:

Hi Samer,

do you have full source code access to both programs, the one writing the file and the one uploading it?

If so, would adding some file locking mechanism ( https://en.wikipedia.org/wiki/File_locking ) help your case?

Cheers,
              Werner

On 19.07.2015 02:50, Samer Afach wrote:

Dear Werner:

Thank you for your response and your time.

I tried modifying the source code of h5check, but it's very complicated and returns strings instead of error codes. Besides, I tried to compile it by including the three files in the main c file and it gave errors that don't seem to be easily trackable. It'll take me lots of time to prepare something reliable out of it with full testing. I wonder why the hdf group didn't implement such a functionality in low language, I thought it exists and I can't find it. :frowning:

About my second question, apparently I wasn't clear on what I really need and I was misunderstood. What I need is to check whether the file I want to read is being accessed by some other program. My problem is that the file I wanna deal with is being written by some other program, and I want to initiate an upload after it's done writing. So I would like to check whether the other program is finished writing and closed it before I send it to my upload queue.

All the best,
Samer

On 18.07.2015 23:11, Werner Benger wrote:

Hi Samer,

On 18.07.2015 16:23, Samer Afach wrote:

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I know there's a software called h5check, but I need a function to do that, not a software. In my application, it's not an option to execute h5check from my system.

Is there any objection against you taking the source code of h5check, rename the main function to h5check_main() and then call it as C function from your code?

2- How can I do a quick check in C/C++ to see whether the file is being written/modified/open for write? I looked in this link <https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which discusses metadata, but there doesn't seem to be a clear way through the C/C++ interface for me a to read the first two bits that give me that information. Could you please help with that with a simple example?

This sounds as if you want to know what the HDF5 library is currently doing with a file? Well what you could do is to modify the virtual file driver that you want to use, and let it keep track of that happens with the file. It's the VFD that does the actual writing of a file content, so you can trace its write() call to keep track what exactly happens when. It's some effort of course.

Cheers,
           Werner

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

Dear Werner:

Thanks for the suggestions. I'll keep these suggestions as last

resort because my program is cross-platform, so I’m trying to avoid
such low-level functions.

I'm thinking now of using an md5 hash of the file instead of the

size. Do you think that would suffice and work? The only problem
with that is that it could be a little expensive, but that’s still
OK if that’s the only problem because the files aren’t really that
big (a few megabytes).

All the best,

Samer
···

On 19.07.2015 16:37, Werner Benger
wrote:

Hi Samer,

  �if those applications are linking dynamically with HDF5, you

could interface there by providing a “patched” version of HDF5
that is binary compatible, but still performs some file locking,
possibly via a modified VFD.

  Just checking the file sizes won't be a sure check, in particular

it would not work for and application that does not append data
but modifies existing ones. You should be able to check the “last
modified” date on the file as well, and if the HDF5 file cannot be
opened by another application, then it’s either corrupted or still
open and data written to it.

  It should also be possible to find out which process has file

handles to a specific file open, both Linux and Windows seem to
allow that, just in an OS-specific way:

  It may require your program to run under admin rights though.

Cheers,
��������� Werner

http://stackoverflow.com/questions/6583158/finding-open-file-descriptors-for-a-process-linux-c-code

https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

    On 19.07.2015 12:32, Samer Afach

wrote:

Dear Werner:

    Unfortunately I don't have the source of the writing program. It

could be anything actually; labview, C, C++, etc… . I’m
working on a collaborative program for collecting data, and my
software is supposed to upload the data to the main storage
server for backup and data analysis. Everyone is free to use any
tools they want for data acquisition.

    Is there any solution to my problem that doesn't involve me

having authority on the writing program? Currently I’m using a
method that I invented, where I measure the size of the file
multiple times, and if the size doesn’t change for some time,
then that decide that the file isn’t being written… that’s the
only way I could come up with, but this has nothing to do with
HDF5.

    All the best,

    Samer
      On 19.07.2015 12:23, Werner Benger

wrote:

Hi Samer,

      �do you have full source code access to both programs, the one

writing the file and the one uploading it?

      If so, would adding some file locking mechanism (� ) help your case?

Cheers,
������������� Werner
https://en.wikipedia.org/wiki/File_locking

        On 19.07.2015 02:50, Samer Afach

wrote:

Dear Werner:

        Thank you for your response and your time.



        I tried modifying the source code of h5check, but it's very

complicated and returns strings instead of error codes.
Besides, I tried to compile it by including the three files
in the main c file and it gave errors that don’t seem to be
easily trackable. It’ll take me lots of time to prepare
something reliable out of it with full testing. I wonder why
the hdf group didn’t implement such a functionality in low
language, I thought it exists and I can’t find it. :frowning:

        About my second question, apparently I wasn't clear on what

I really need and I was misunderstood. What I need is to
check whether the file I want to read is being accessed by
some other program. My problem is that the file I wanna deal
with is being written by some other program, and I want to
initiate an upload after it’s done writing. So I would like
to check whether the other program is finished writing and
closed it before I send it to my upload queue.

        All the best,

        Samer
          On 18.07.2015 23:11, Werner

Benger wrote:

Hi Samer,

          Is there any objection against you taking the source code

of h5check, rename the main function to h5check_main() and
then call it as C function from your code?
This sounds as if you want to know what the HDF5 library
is currently doing with a file? Well what you could do is
to modify the virtual file driver that you want to use,
and let it keep track of that happens with the file. It’s
the VFD that does the actual writing of a file content, so
you can trace its write() call to keep track what exactly
happens when. It’s some effort of course.
Cheers,
���������� Werner
On 18.07.2015 16:23, Samer
Afach wrote:

Dear pros:

            I have two similar issues I would like to ask about, and

I’d be grateful if you could help me:

            1- How can I check HDF5 file integrity in C/C++ (I

prefer low level C)? I know there’s a software called
h5check, but I need a function to do that, not a
software. In my application, it’s not an option to
execute h5check from my system.

            2- How can I do a quick check in C/C++ to

see whether the file is being written/modified/open for
write? I looked [

              in

this link](https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData) which discusses metadata, but there
doesn’t seem to be a clear way through the C/C++
interface for me a to read the first two bits that give
me that information. Could you please help with that
with a simple example?

All the best,

            Samer


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

Dear Werner:

Thanks for the suggestions. I'll keep these suggestions as last resort
because my program is cross-platform, so I'm trying to avoid such low-level
functions.

I'm thinking now of using an md5 hash of the file instead of the size. Do
you think that would suffice and work? The only problem with that is that
it could be a little expensive, but that's still OK if that's the only
problem because the files aren't really that big (a few megabytes).

If might be more efficient to use a file synchronization system, or maybe
just run rsync periodically.

···

On Sun, Jul 19, 2015 at 11:47 AM, Samer Afach <webmaster@afach.de> wrote:

All the best,
Samer

On 19.07.2015 16:37, Werner Benger wrote:

Hi Samer,

if those applications are linking dynamically with HDF5, you could
interface there by providing a "patched" version of HDF5 that is binary
compatible, but still performs some file locking, possibly via a modified
VFD.

Just checking the file sizes won't be a sure check, in particular it would
not work for and application that does not append data but modifies
existing ones. You should be able to check the "last modified" date on the
file as well, and if the HDF5 file cannot be opened by another application,
then it's either corrupted or still open and data written to it.

It should also be possible to find out which process has file handles to a
specific file open, both Linux and Windows seem to allow that, just in an
OS-specific way:

http://stackoverflow.com/questions/6583158/finding-open-file-descriptors-for-a-process-linux-c-code

https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

It may require your program to run under admin rights though.

Cheers,
          Werner

On 19.07.2015 12:32, Samer Afach wrote:

Dear Werner:

Unfortunately I don't have the source of the writing program. It could be
anything actually; labview, C, C++, etc... . I'm working on a collaborative
program for collecting data, and my software is supposed to upload the data
to the main storage server for backup and data analysis. Everyone is free
to use any tools they want for data acquisition.

Is there any solution to my problem that doesn't involve me having
authority on the writing program? Currently I'm using a method that I
invented, where I measure the size of the file multiple times, and if the
size doesn't change for some time, then that decide that the file isn't
being written... that's the only way I could come up with, but this has
nothing to do with HDF5.

All the best,
Samer

On 19.07.2015 12:23, Werner Benger wrote:

Hi Samer,

do you have full source code access to both programs, the one writing the
file and the one uploading it?

If so, would adding some file locking mechanism (
<https://en.wikipedia.org/wiki/File_locking>
https://en.wikipedia.org/wiki/File_locking ) help your case?

Cheers,
              Werner

On 19.07.2015 02:50, Samer Afach wrote:

Dear Werner:

Thank you for your response and your time.

I tried modifying the source code of h5check, but it's very complicated
and returns strings instead of error codes. Besides, I tried to compile it
by including the three files in the main c file and it gave errors that
don't seem to be easily trackable. It'll take me lots of time to prepare
something reliable out of it with full testing. I wonder why the hdf group
didn't implement such a functionality in low language, I thought it exists
and I can't find it. :frowning:

About my second question, apparently I wasn't clear on what I really need
and I was misunderstood. What I need is to check whether the file I want to
read is being accessed by some other program. My problem is that the file I
wanna deal with is being written by some other program, and I want to
initiate an upload after it's done writing. So I would like to check
whether the other program is finished writing and closed it before I send
it to my upload queue.

All the best,
Samer

On 18.07.2015 23:11, Werner Benger wrote:

Hi Samer,

On 18.07.2015 16:23, Samer Afach wrote:

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful
if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I
know there's a software called h5check, but I need a function to do that,
not a software. In my application, it's not an option to execute h5check
from my system.

Is there any objection against you taking the source code of h5check,
rename the main function to h5check_main() and then call it as C function
from your code?

2- How can I do a quick check in C/C++ to see whether the file is being
written/modified/open for write? I looked in this link
<https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which
discusses metadata, but there doesn't seem to be a clear way through the
C/C++ interface for me a to read the first two bits that give me that
information. Could you please help with that with a simple example?

This sounds as if you want to know what the HDF5 library is currently
doing with a file? Well what you could do is to modify the virtual file
driver that you want to use, and let it keep track of that happens with the
file. It's the VFD that does the actual writing of a file content, so you
can trace its write() call to keep track what exactly happens when. It's
some effort of course.

Cheers,
           Werner

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
George N. White III <aa056@chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia

I recommend git-annex for tracking HDF5 files:

https://git-annex.branchable.com

git-annex is the perfect tool for verifying the integrity of
data files and replicating them between multiple locations.

Peter

···

On Sun, Jul 19, 2015 at 04:47:32PM +0200, Samer Afach wrote:

I'm thinking now of using an md5 hash of the file instead of the size. Do
you think that would suffice and work? The only problem with that is that
it could be a little expensive, but that's still OK if that's the only
problem because the files aren't really that big (a few megabytes).

Hi Samer,

it would look easier to me to just check the last write time, under windows this is function GetFileTime:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724320(v=vs.85).aspx

under Linux, stat() should do. Building an md5 hash seems like a slower version, but both couldn't catch
the case where an application opens a file, writes data, close it, opens the file again, adds more data,
closes it again.... but neither would the locking mechanism or the file handle approach help in that case.

So maybe checking the file write time would be best. At first you could measure how frequently a file
is modified, e.g. you find out every minute. Then if you measure that the file has not been modified for
10 minutes, it's assumed the file will no longer be modified. It wouldn't catch the case that an application
is writing data to the file and they still remain in write cache with the file being kept open but the application
is doing something different for a while. However, it seems it requires some kind of "guessing" anyway what
the writing application is doing, especially if it would repeatedly close and re-open the same file to append data.

Cheers,
       Werner

···

On 19.07.2015 16:47, Samer Afach wrote:

Dear Werner:

Thanks for the suggestions. I'll keep these suggestions as last resort because my program is cross-platform, so I'm trying to avoid such low-level functions.

I'm thinking now of using an md5 hash of the file instead of the size. Do you think that would suffice and work? The only problem with that is that it could be a little expensive, but that's still OK if that's the only problem because the files aren't really that big (a few megabytes).

All the best,
Samer

On 19.07.2015 16:37, Werner Benger wrote:

Hi Samer,

if those applications are linking dynamically with HDF5, you could interface there by providing a "patched" version of HDF5 that is binary compatible, but still performs some file locking, possibly via a modified VFD.

Just checking the file sizes won't be a sure check, in particular it would not work for and application that does not append data but modifies existing ones. You should be able to check the "last modified" date on the file as well, and if the HDF5 file cannot be opened by another application, then it's either corrupted or still open and data written to it.

It should also be possible to find out which process has file handles to a specific file open, both Linux and Windows seem to allow that, just in an OS-specific way:

http://stackoverflow.com/questions/6583158/finding-open-file-descriptors-for-a-process-linux-c-code

https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

It may require your program to run under admin rights though.

Cheers,
          Werner

On 19.07.2015 12:32, Samer Afach wrote:

Dear Werner:

Unfortunately I don't have the source of the writing program. It could be anything actually; labview, C, C++, etc... . I'm working on a collaborative program for collecting data, and my software is supposed to upload the data to the main storage server for backup and data analysis. Everyone is free to use any tools they want for data acquisition.

Is there any solution to my problem that doesn't involve me having authority on the writing program? Currently I'm using a method that I invented, where I measure the size of the file multiple times, and if the size doesn't change for some time, then that decide that the file isn't being written... that's the only way I could come up with, but this has nothing to do with HDF5.

All the best,
Samer

On 19.07.2015 12:23, Werner Benger wrote:

Hi Samer,

do you have full source code access to both programs, the one writing the file and the one uploading it?

If so, would adding some file locking mechanism ( https://en.wikipedia.org/wiki/File_locking ) help your case?

Cheers,
              Werner

On 19.07.2015 02:50, Samer Afach wrote:

Dear Werner:

Thank you for your response and your time.

I tried modifying the source code of h5check, but it's very complicated and returns strings instead of error codes. Besides, I tried to compile it by including the three files in the main c file and it gave errors that don't seem to be easily trackable. It'll take me lots of time to prepare something reliable out of it with full testing. I wonder why the hdf group didn't implement such a functionality in low language, I thought it exists and I can't find it. :frowning:

About my second question, apparently I wasn't clear on what I really need and I was misunderstood. What I need is to check whether the file I want to read is being accessed by some other program. My problem is that the file I wanna deal with is being written by some other program, and I want to initiate an upload after it's done writing. So I would like to check whether the other program is finished writing and closed it before I send it to my upload queue.

All the best,
Samer

On 18.07.2015 23:11, Werner Benger wrote:

Hi Samer,

On 18.07.2015 16:23, Samer Afach wrote:

Dear pros:

I have two similar issues I would like to ask about, and I'd be grateful if you could help me:

1- How can I check HDF5 file integrity in C/C++ (I prefer low level C)? I know there's a software called h5check, but I need a function to do that, not a software. In my application, it's not an option to execute h5check from my system.

Is there any objection against you taking the source code of h5check, rename the main function to h5check_main() and then call it as C function from your code?

2- How can I do a quick check in C/C++ to see whether the file is being written/modified/open for write? I looked in this link <https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData> which discusses metadata, but there doesn't seem to be a clear way through the C/C++ interface for me a to read the first two bits that give me that information. Could you please help with that with a simple example?

This sounds as if you want to know what the HDF5 library is currently doing with a file? Well what you could do is to modify the virtual file driver that you want to use, and let it keep track of that happens with the file. It's the VFD that does the actual writing of a file content, so you can trace its write() call to keep track what exactly happens when. It's some effort of course.

Cheers,
           Werner

All the best,
Samer

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter:https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

--
___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

Dear Werner:

Thank you very much for your help. I think boost::filesystem can

look for the last writing time. I’m gonna do that.

On the other hand, I kindly request the HDF group to create

something out of h5check to check the integrity of hdf files and I’d
be greatful.

Thank you for your help and time.

Cheers,

Samer
···

On 19.07.2015 18:52, Werner Benger
wrote:

Hi Samer,

  it would look easier to me to just check the last write time,

under windows this is function GetFileTime:

  under Linux, stat() should do. Building an md5 hash seems like a

slower version, but both couldn’t catch
the case where an application opens a file, writes data, close it,
opens the file again, adds more data,
closes it again… but neither would the locking mechanism or the
file handle approach help in that case.
So maybe checking the file write time would be best. At first you
could measure how frequently a file
is modified, e.g. you find out every minute. Then if you measure
that the file has not been modified for
10 minutes, it’s assumed the file will no longer be modified. It
wouldn’t catch the case that an application
is writing data to the file and they still remain in write cache
with the file being kept open but the application
is doing something different for a while. However, it seems it
requires some kind of “guessing” anyway what
the writing application is doing, especially if it would
repeatedly close and re-open the same file to append data.
Cheers,
����� Werner

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724320%28v=vs.85%29.aspx

    On 19.07.2015 16:47, Samer Afach

wrote:

Dear Werner:

    Thanks for the suggestions. I'll keep these suggestions as last

resort because my program is cross-platform, so I’m trying to
avoid such low-level functions.

    I'm thinking now of using an md5 hash of the file instead of the

size. Do you think that would suffice and work? The only problem
with that is that it could be a little expensive, but that’s
still OK if that’s the only problem because the files aren’t
really that big (a few megabytes).

    All the best,

    Samer
      On 19.07.2015 16:37, Werner Benger

wrote:

Hi Samer,

      �if those applications are linking dynamically with HDF5, you

could interface there by providing a “patched” version of HDF5
that is binary compatible, but still performs some file
locking, possibly via a modified VFD.

      Just checking the file sizes won't be a sure check, in

particular it would not work for and application that does not
append data but modifies existing ones. You should be able to
check the “last modified” date on the file as well, and if the
HDF5 file cannot be opened by another application, then it’s
either corrupted or still open and data written to it.

      It should also be possible to find out which process has file

handles to a specific file open, both Linux and Windows seem
to allow that, just in an OS-specific way:

      It may require your program to run under admin rights though.

Cheers,
��������� Werner
http://stackoverflow.com/questions/6583158/finding-open-file-descriptors-for-a-process-linux-c-code

https://technet.microsoft.com/en-us/sysinternals/bb896653.aspx

        On 19.07.2015 12:32, Samer Afach

wrote:

Dear Werner:

        Unfortunately I don't have the source of the writing

program. It could be anything actually; labview, C, C++,
etc… . I’m working on a collaborative program for
collecting data, and my software is supposed to upload the
data to the main storage server for backup and data
analysis. Everyone is free to use any tools they want for
data acquisition.

        Is there any solution to my problem that doesn't involve me

having authority on the writing program? Currently I’m using
a method that I invented, where I measure the size of the
file multiple times, and if the size doesn’t change for some
time, then that decide that the file isn’t being written…
that’s the only way I could come up with, but this has
nothing to do with HDF5.

        All the best,

        Samer
          On 19.07.2015 12:23, Werner

Benger wrote:

Hi Samer,

          �do you have full source code access to both programs, the

one writing the file and the one uploading it?

          If so, would adding some file locking mechanism (� ) help your case?

Cheers,
������������� Werner
https://en.wikipedia.org/wiki/File_locking

            On 19.07.2015 02:50, Samer

Afach wrote:

Dear Werner:

            Thank you for your response and your time.



            I tried modifying the source code of h5check, but it's

very complicated and returns strings instead of error
codes. Besides, I tried to compile it by including the
three files in the main c file and it gave errors that
don’t seem to be easily trackable. It’ll take me lots of
time to prepare something reliable out of it with full
testing. I wonder why the hdf group didn’t implement
such a functionality in low language, I thought it
exists and I can’t find it. :frowning:

            About my second question, apparently I wasn't clear on

what I really need and I was misunderstood. What I need
is to check whether the file I want to read is being
accessed by some other program. My problem is that the
file I wanna deal with is being written by some other
program, and I want to initiate an upload after it’s
done writing. So I would like to check whether the other
program is finished writing and closed it before I send
it to my upload queue.

            All the best,

            Samer
              On 18.07.2015 23:11, Werner

Benger wrote:

Hi Samer,

              Is there any objection against you taking the source

code of h5check, rename the main function to
h5check_main() and then call it as C function from
your code?
This sounds as if you want to know what the HDF5
library is currently doing with a file? Well what you
could do is to modify the virtual file driver that you
want to use, and let it keep track of that happens
with the file. It’s the VFD that does the actual
writing of a file content, so you can trace its
write() call to keep track what exactly happens when.
It’s some effort of course.
Cheers,
���������� Werner
On 18.07.2015 16:23,
Samer Afach wrote:

Dear pros:

                I have two similar issues I would like to ask about,

and I’d be grateful if you could help me:

                1- How can I check HDF5 file integrity in C/C++ (I

prefer low level C)? I know there’s a software
called h5check, but I need a function to do that,
not a software. In my application, it’s not an
option to execute h5check from my system.

                2- How can I do a quick check in C/C++

to see whether the file is being
written/modified/open for write? I looked [

                  in

this link](https://www.hdfgroup.org/HDF5/doc/H5.format.html#FileMetaData) which discusses metadata, but there
doesn’t seem to be a clear way through the C/C++
interface for me a to read the first two bits that
give me that information. Could you please help with
that with a simple example?

All the best,

                Samer


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5


_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5

-- ___________________________________________________________________________
Dr. Werner Benger Visualization Research
Center for Computation & Technology at Louisiana State University (CCT/LSU)
2019 Digital Media Center, Baton Rouge, Louisiana 70803
Tel.: +1 225 578 4809 Fax.: +1 225 578-5362

_______________________________________________
Hdf-forum is for HDF software users discussion.
Twitter:

Hdf-forum@lists.hdfgroup.orghttp://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.orghttps://twitter.com/hdf5