/**
  * Constructs an HDF5 group with specific name, path, and parent.
  *
  * @param theFile
  *            the file which containing the group.
  * @param name
  *            the name of this group, e.g. "grp01".
  * @param path
  *            the full path of this group, e.g. "/groups/".
  * @param parent
  *            the parent of this group.
  */
 public H5Group(FileFormat theFile, string name, string path, Group parent) : this(theFile, name, path, parent, IntPtr.Zero)
 {
 }
Exemple #2
0
        public HObject(FileFormat theFile, string theName, string thePath, IntPtr oid)
        {
            fileFormat   = theFile;
            this.address = oid;

            if (fileFormat != null)
            {
                filename = fileFormat.GetFilePath();
            }
            else
            {
                filename = null;
            }

            // file name is packed in the full path
            if ((theName == null) && (thePath != null))
            {
                if (thePath.Equals(SEPARATOR))
                {
                    theName = SEPARATOR;
                    thePath = null;
                }
                else
                {
                    // the path must starts with "/"
                    if (!thePath.StartsWith(SEPARATOR))
                    {
                        thePath = SEPARATOR + thePath;
                    }

                    // get rid of the last "/"
                    if (thePath.EndsWith(SEPARATOR))
                    {
                        thePath = thePath.Substring(0, thePath.Length - 1);
                    }

                    // separate the name and the path
                    theName = thePath.Substring(thePath.LastIndexOf(SEPARATOR) + 1);
                    thePath = thePath.Substring(0, thePath.LastIndexOf(SEPARATOR));
                }
            }
            else if ((theName != null) && (thePath == null) && (theName.IndexOf(SEPARATOR) >= 0))
            {
                if (theName.Equals(SEPARATOR))
                {
                    theName = SEPARATOR;
                    thePath = null;
                }
                else
                {
                    // the full name must starts with "/"
                    if (!theName.StartsWith(SEPARATOR))
                    {
                        theName = SEPARATOR + theName;
                    }

                    // the fullname must not end with "/"
                    int n = theName.Length;
                    if (theName.EndsWith(SEPARATOR))
                    {
                        theName = theName.Substring(0, n - 1);
                    }

                    int idx = theName.LastIndexOf(SEPARATOR);
                    if (idx < 0)
                    {
                        thePath = SEPARATOR;
                    }
                    else
                    {
                        thePath = theName.Substring(0, idx);
                        theName = theName.Substring(idx + 1);
                    }
                }
            }

            // the path must start and end with "/"
            if (thePath != null)
            {
                thePath = thePath.Replace("//", "/");
                if (!thePath.EndsWith(SEPARATOR))
                {
                    thePath += SEPARATOR;
                }
            }

            name = theName;
            path = thePath;

            Hdf5Utils.LogInfo?.Invoke($"name={name} path={path}");

            if (thePath != null)
            {
                fullName = thePath + theName;
            }
            else
            {
                if (theName == null)
                {
                    fullName = "/";
                }
                else if (theName.StartsWith("/"))
                {
                    fullName = theName;
                }
                else
                {
                    if (this is HAttribute)
                    {
                        fullName = theName;
                    }
                    else
                    {
                        fullName = "/" + theName;
                    }
                }
            }

            Hdf5Utils.LogInfo?.Invoke("fullName=" + fullName);
        }
Exemple #3
0
 public Group(FileFormat theFile, string grpName, string grpPath, Group grpParent, IntPtr oid) : base(theFile,
                                                                                                      grpName, grpPath, oid)
 {
     this.parent = grpParent;
 }
Exemple #4
0
 /**
  * Constructs an instance of a data object with specific name and path.
  * <p>
  * For example, in H5ScalarDS(h5file, "dset", "/arrays"), "dset" is the name
  * of the dataset, "/arrays" is the group path of the dataset.
  *
  * @param theFile
  *            the file that contains the data object.
  * @param theName
  *            the name of the data object, e.g. "dset".
  * @param thePath
  *            the group path of the data object, e.g. "/arrays".
  */
 public HObject(FileFormat theFile, string theName, string thePath) : this(theFile, theName, thePath, IntPtr.Zero)
 {
 }
Exemple #5
0
 /**
  * Constructs an instance of the group with specific name, path and parent
  * group. An HDF data object must have a name. The path is the group path
  * starting from the root. The parent group is the group where this group is
  * located.
  * <p>
  * For example, in H5Group(h5file, "grp", "/groups/", pgroup), "grp" is the
  * name of the group, "/groups/" is the group path of the group, and pgroup
  * is the group where "grp" is located.
  *
  * @param theFile
  *            the file containing the group.
  * @param grpName
  *            the name of this group, e.g. "grp01".
  * @param grpPath
  *            the full path of this group, e.g. "/groups/".
  * @param grpParent
  *            the parent of this group.
  */
 public Group(FileFormat theFile, string grpName, string grpPath, Group grpParent) : this(theFile, grpName, grpPath, grpParent, IntPtr.Zero)
 {
 }