Problem with creating files under the window path

Can anyone help me on how to generate it with hdfql under windows. h5 file I run the code below generated below the specified directory. h5 file failed?

    private void BtnCreateHDF5_Click(object sender, RoutedEventArgs e)
    {
        Stopwatch sw = Stopwatch.StartNew();

        sw.Start();

        string pathname = "";
        string dbname = "F:\\test1\\hdf5_data.h5";

        ushort[,,] values = new ushort[1, 200, 800];
        
        //HDFql.Execute("USE DIRECTORY " + pathname);
        HDFql.Execute("CREATE FILE " + dbname);
        HDFql.Execute("USE FILE " + dbname);

        HDFql.Execute("CREATE GROUP /Data/GR-1 ORDER TRACKED");
        HDFql.Execute("CREATE CHUNKED(1,200, 800) DATASET /Data/GR-1/MyData " +
            "AS UNSIGNED SMALLINT(UNLIMITED, 200,800) ENABLE FLETCHER32");

        Random random = new Random();

        for (int i = 0; i < 200; i++)
        {
            for (int j = 0; j < 800; j++)
            {
                values[0, i, j] = (ushort)(random.Next(60000));
            }
        }

        HDFql.Execute("INSERT INTO /Data/GR-1/MyData VALUES FROM MEMORY "
            + HDFql.VariableTransientRegister(values));
        HDFql.Execute("CLOSE FILE");

        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        string ss = "HDF5 Insert Data 10000:  " + ts.TotalSeconds.ToString("0.0000");

        AddMemoInfo(ss);

    }

Hi @meng_1226,

Would you mind surrounding dbname with double-quotes as it contains special characters (e.g. :). In other words (and simplifying your code):

HDFql.Execute("CREATE AND USE FILE \"" + dbname + "\"");

Hope it helps!

        string dbname = "\"F:\\test1\\hdf5_data.h5\"";
        
        //HDFql.Execute("USE DIRECTORY " + pathname);
        HDFql.Execute("CREATE FILE " + dbname);
        HDFql.Execute("USE FILE " + dbname);

To still create the F:\test1\hdf5_data.h5 file has failed,
HDFql. Execute Execution is returned as fail

Hi @meng_1226,

Do you have access to F:\\test1? Also, would you mind to share the return code of Execute as follows:

Console.WriteLine(HDFql.Execute("CREATE FILE " + dbname));

Uploading: ret.png…
return = -4

Thanks for sharing the return code.

According to HDFql reference manual, return code -4 (HDFQL_ERROR_NO_ACCESS) means that a directory, file or object cannot be accessed.

Are you sure to have access to F:\\test1?

maybe windows path problem, HDFql using posix!

Would you mind trying string dbname = "\"F:\\\\test1\\hdf5_data.h5\""; or string dbname = @“”"F:\\test1\\hdf5_data.h5\"”"; and see how it goes?

Thanks so much for your reply, but still not

Would you mind checking if you have access to F:\\test1?

The test program I wrote is available in D:\projects\hdftest1,
If I use this
string dbname = “hdf5_data.h5”;
He can generate a file under the directory of the program, but not if he changes the disk character

F: \test1 This directory can be accessed

Is it a problem with the posix style path???

Who can help me to be appreciated!!

I also see this problem when using HDFql. I cannot use paths which include a drive letter (or UNC paths).
“\directory\filename.hdf5” is OK
“C:\directory\filename.hdf5” fails with error code -4

To work around this problem with your example F:\test1\hdf5_data.h5 :

  • check if file path starts with drive letter ( F:)
    • push current working directory
    • remove drive letter: from filename (leaving \test1\hdf5_data.h5 in your example)
    • change working directory to drive letter (F:)
    • perform desired HDFql operation using filename without drive letter
    • pop to original working directory

You’ll need to wrap this around any HDFql operations which specify a filename such as CREATE, USE, CLOSE, DROP

It would be very nice if HDFql did this for us!

Hi @meng_1226 and @andrew_fisher,

Would you mind surrounding the path/file name with " (as it contains the reserved character : from HDFql point of view) and escaping all its \ (as \ is a reserved character in C#)? In other words, please try the following and see if it works properly now:

HDFql.Execute("USE FILE \"F:\\test1\\hdf5_data.h5\"");

Hope it helps!

Thanks for the suggestion.

Using quotes around the path / filename does not fix this issue. It allows a drive letter to be included in the path, but the file will only be successfully created / opened if my program is running from the same drive letter.

Program running from C: drive, quoted path with drive letter on C: drive
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“C:\\test1\\filename.hdf5\””);
–Success

Program running from D: drive, quoted path with drive letter on D: drive
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“D:\\test1\\filename.hdf5\””);
–Success

Program running from C: drive, quoted path with drive letter on D: drive
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“D:\\test1\\filename.hdf5\””);
Error code -4

Program running from D: drive, quoted path with drive letter on C: drive
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“C:\\test1\\filename.hdf5\””);
Error code -4

Unquoted path including drive letter
HDFql::execute(“CREATE TRUNCATE AND USE FILE C:\\test1\\filename.hdf5”);
–Error code -1

I’m using HDFql 2.5.0 with C++

1 Like

Hi @andrew_fisher,

Thanks for the detailed report!

At our side, we tested HDFql using different drives (i.e. running a program on one drive and creating and accessing an HDF5 file on another drive) and it worked perfectly fine. Given that you are working in C/C++, would you mind running your test cases once more, this time using the HDF5 library function H5Fcreate to create and access an HDF5 file and see how it goes? Just to understand where the issue lies.

Hi @andrew_fisher,

Have you had a chance to try out the (problematic) use-case with the HDF5 library function yet?