# Hdfview should default to read-only open

**URL:** <https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584>\
**Category:** HDFView / Java HDF Object Package\
**Created:** [July 3, 2018, 9:19pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584 "2018-07-03T21:19:24Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![miller86](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/miller86/32/124_2.png) [@miller86](https://forum.hdfgroup.org/u/miller86)\
**Post date:** [July 3, 2018, 9:19pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/1 "2018-07-03T21:19:24Z")

</div>

I ran hdfview like so…

> /path/HDFView-3.0.0-Linux/HDFView/3.0.0/hdfview.sh myfile.h5

Its a 1.5 GB file with a ton of directories and objects in it.

hdfview OOM’d. That is bad. Worse, it corrupted the file.

When a file is given on the command-line, I think it should default to opening that file read-only. In addition, if data corruption is a potential issue with hdfview, then I would recommend that ‘open’ in the GUI means read-only and a separate open-for-write be provided.

I think the default open for writing is too risk, particularly given this experience.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [July 3, 2018, 9:43pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/2 "2018-07-03T21:43:13Z")

</div>

Yes, next release defaults to read-only mode.

---

<div class="post-metadata">

**Author:** ![miller86](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/miller86/32/124_2.png) [@miller86](https://forum.hdfgroup.org/u/miller86)\
**Post date:** [October 22, 2018, 5:37pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/3 "2018-10-22T17:37:33Z")

</div>

Maybe the headline of this thread should be changed to _all_ HDF5 tools should default to read-only open. I just tried using h5ls on a file that I was already looking at in hdfview and h5ls failed with error “unable to open file”. I suspect this is because the file may already have been corrupted by hdfview. But, I was using hdfview _and_ h5ls from 1.10.2 install.

And, it just seems prudent that _all_ HDF5 tools should open files read-only and users should have to take action (with cl args or something) if they want read-write.

---

<div class="post-metadata">

**Author:** ![bljones](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@bljones](https://forum.hdfgroup.org/u/bljones)\
**Post date:** [October 22, 2018, 6:45pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/4 "2018-10-22T18:45:18Z")

</div>

Hi Mark,

The h5ls (or h5dump) utility does not appear to modify an HDF5 file.

The beta version of HDFView 3.0 _ **did** _ modify an HDF5 by default. As of the released version of HDFView 3.0 (that uses HDF5-1.10.3) we changed the behavior so that an HDF5 file is not modified by default, and you can change the default way files are opened by selecting User Options from the Tools menu at the top of the HDFView window. (HOWEVER, if you had the HDFView 3.0 beta installed previously, the default will be read-write, because the HDFView 3.0 options file (.hdfviewx) is already there (unless you delete it first).

If you are on Windows, you will get an “unable to open file” error if you have a file opened in HDFView, and you try running h5ls on the file. Windows only allows one file to be open at a time. The timestamp will also appear to be modified, but when HDFView closes the file, the timestamp on the file will revert back to the original timestamp.

On Unix, you should be able to open the file in HDFView and use h5ls at the same time.

-Barbara

---

<div class="post-metadata">

**Author:** ![miller86](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/miller86/32/124_2.png) [@miller86](https://forum.hdfgroup.org/u/miller86)\
**Post date:** [October 22, 2018, 6:49pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/5 "2018-10-22T18:49:32Z")

</div>

Ok, well, the problem with h5ls opening the file then must have been that hdfview had already corrupted it. Which is strange because hdfview seemed to continue to work on the file just fine 😉

The mode of operation you describe for these tools is, IMHO, the preferred one.

Thanks

---

<div class="post-metadata">

**Author:** ![jpsinfotech](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@jpsinfotech](https://forum.hdfgroup.org/u/jpsinfotech)\
**Post date:** [June 4, 2019, 7:38pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/6 "2019-06-04T19:38:17Z")

</div>

> [@miller86](#):
>
> Maybe the headline of this thread should be changed to _all_ HDF5 tools should default to read-only open. I just tried using h5ls on a file that I was already looking at in hdfview and h5ls failed with error “unable to open file”. I suspect this is because the file may already have been corrupted by hdfview. But, I was using hdfview _and_ h5ls from 1.10.2 install.
> 
> And, it just seems prudent that _all_ HDF5 tools should open files read-only and users should have to take action (with cl args or something) if they want read-write.

I believe HDFView 3.1.0 is opening the hdf5 file in Write mode(by default)… It has the settings called default File access mode. But i believe it didn’t work.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [June 5, 2019, 1:57pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/7 "2019-06-05T13:57:17Z")

</div>

The latest HDFView will use the value last set in User Options in the users property file.  
If there is an existing property file is will that value, if there is no property file it will default to RO.

Allen

---

<div class="post-metadata">

**Author:** ![jpsinfotech](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@jpsinfotech](https://forum.hdfgroup.org/u/jpsinfotech)\
**Post date:** [June 14, 2019, 1:22pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/8 "2019-06-14T13:22:52Z")

</div>

> [@byrn](#):
>
> ere is an existing property file is will that value, if there is no property file it will default to

i have set the value as Read only in the User options(under Tools menu).  
By default if am I opening the hdf file via the file menu, it opens a read only.  
If I double clik file for opening, it always opens as Write mode.

Can you please let me know more about the property file.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [June 14, 2019, 1:39pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/9 "2019-06-14T13:39:16Z")

</div>

The settings in the User Options should be saved in a property file in the root user folder; by default “.hdfview-3.1”

The double click of a file from the file system which then opens up the file with HDFView should use the setting in the property file. It is a bug otherwise.

I will investigate,  
Allen

---

<div class="post-metadata">

**Author:** ![joel.conraud](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/j/ec9cab/32.png) [@joel.conraud](https://forum.hdfgroup.org/u/joel.conraud)\
**Post date:** [June 25, 2019, 8:19pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/10 "2019-06-25T20:19:35Z")

</div>

It is possible on windows to have a file open by multiple processes at the same time.  
Just launch h5ls with a redirection of its ouput into a log file, open this log file in a text editor such visual code during h5ls work. The log file is open by both h5ls and visual code, and it works.  
Could be interesting to investigate how visual code is able to read a file during its generation by another process.

-Joël

---

<div class="post-metadata">

**Author:** ![erik.maansson](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/e95f7d/32.png) [@erik.maansson](https://forum.hdfgroup.org/u/erik.maansson)\
**Post date:** [June 24, 2021, 1:55pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/11 "2021-06-24T13:55:15Z")

</div>

Dear all,

As jpsinfotech write in 2019, and I confirm now with HDFView 3.1.0 as well as 3.1.2:

- The Tools -\> User options -\> Default File Access Mode has the desired effect on the configuration file (`C:\Users\USERNAME\.hdfview3.1.2`) and for when you use the File -\> Open menu entry to open a file.
- But if you open a file via the command line (`hdfview.bat some_file.h5`) or by having a filename extension associated to launch such a command when a file is double-clicked in the Windows Explorer, **then the setting is ignored** and the file is opened in writable mode.

To check which mode was used, I navigate to any dataset in my file, double-click it to get the table-window and then double-click a cell. When read-only mode the cell just gets selected, while in writable mode the cell becomes a text editor and I can type another value (e.g. for uint32) or text (for a string). When closing the table-window a dialog-box asks me whether to save or cancel.

Thus I am pretty sure that there is still a bug somewhere. Perhaps when launched with a filename on the command line the opening starts before the configuration has been loaded or applied? Or perhaps the command-line opening uses a different function than the File -\> Open menu action?

Since the default configuration is now read-only (even if it fails to work when a filename is given by command line), the documentation also needs to be updated (after fixing the bug):  
Page 80 of the PDF on [https://confluence.hdfgroup.org/display/HDFVIEW/HDFView+3.x+User’s+Guide](https://confluence.hdfgroup.org/display/HDFVIEW/HDFView+3.x+User's+Guide) says “7.1.3 File Access Mode: By default, HDFView opens files in editing mode”  
and on [https://support.hdfgroup.org/products/java/hdfview/UsersGuide/ug08useroptions.html#ug08fileaccess](https://support.hdfgroup.org/products/java/hdfview/UsersGuide/ug08useroptions.html#ug08fileaccess)  
“8.1.3 File Access Mode: By default, HDFView opens files in editing mode”.

Although fixing the default behavior would be enough for me, it could potentially be useful to add a command-line argument to override the default, e.g. `-file.mode=r` or `-file.mode=rw`.

To describe my motivations for wanting to be sure files are opened read-only:

- We store scientific raw-data from multiple users on a network storage, read-only for most users but some have elevated permission with the intent of being able to reorganize files in directories etc., but we don’t want to make it easy to edit contents or corrupt files by having multiple users open them as writable at the same time.
- It is also ugly that the filesystem timestamps for files are no longer showing when they were acquired, but the last time that someone just double-clicked the file to read out something with HDFView (which happens with the read-write mode even if the user makes no change in any dataset).

---

<div class="post-metadata">

**Author:** ![Hakon\_Strandenes](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/h/77aa72/32.png) [@Hakon\_Strandenes](https://forum.hdfgroup.org/u/Hakon_Strandenes)\
**Post date:** [June 28, 2021, 1:47pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/12 "2021-06-28T13:47:59Z")

</div>

I just checked on my Linux box and can confirm the general behavior described above. When opening an HDF5 file with HDFView 3.1.2 directly form the command line `hdfview.sh file.h5` the file is opened read-write. When HDFView is launched first and the file is opened from the menus, it is by default opened read-only.

Standard setting from Tools-\>User options is to open ad read-only.

Since I never use HDFView for any other purpose than inspecting the contents of a file, I would ideally have it read-only.

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [June 28, 2021, 3:59pm UTC](https://forum.hdfgroup.org/t/hdfview-should-default-to-read-only-open/4584/13 "2021-06-28T15:59:17Z")

</div>

Yes I believe we have fixed this in the next release. Unfortunately, we are having issues with creating HDFView on a mac at the moment, which is the final holdup.
