Esempio n. 1
0
        /// <summary>
        /// Open a WIM file and create a ::WIMStruct for it.
        /// </summary>
        /// <param name="wimFile">The path to the WIM file to open.</param>
        /// <param name="openFlags">Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.</param>
        /// <returns>
        /// On success, a pointer to a new ::WIMStruct backed by the specified
        ///	on-disk WIM file is written to the memory location pointed to by this
        ///	parameter.This ::WIMStruct must be freed using using wimlib_free()
        ///	when finished with it.
        ///	</returns>
        ///	<exception cref="WimLibException">wimlib does not return WIMLIB_ERR_SUCCESS.</exception>
        public static Wim OpenWim(string wimFile, WimLibOpenFlags openFlags)
        {
            WimLibErrorCode ret = WimLibNative.OpenWim(wimFile, openFlags, out IntPtr wimPtr);

            if (ret != WimLibErrorCode.SUCCESS)
            {
                throw new WimLibException(ret);
            }

            return(new Wim(wimPtr));
        }
Esempio n. 2
0
        /// <summary>
        /// Same as wimlib_open_wim(), but allows specifying a progress function and\
        /// progress context.  If successful, the progress function will be registered in
        /// the newly open ::WIMStruct, as if by an automatic call to
        /// wimlib_register_progress_function().  In addition, if
        /// ::WIMLIB_OPEN_FLAG_CHECK_INTEGRITY is specified in @p open_flags, then the
        /// progress function will receive ::WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY
        /// messages while checking the WIM file's integrity.
        /// </summary>
        /// <param name="wimFile">The path to the WIM file to open.</param>
        /// <param name="openFlags">Bitwise OR of flags prefixed with WIMLIB_OPEN_FLAG.</param>
        /// <returns>
        /// On success, a pointer to a new ::WIMStruct backed by the specified
        ///	on-disk WIM file is written to the memory location pointed to by this
        ///	parameter.This ::WIMStruct must be freed using using wimlib_free()
        ///	when finished with it.
        ///	</returns>
        ///	<exception cref="WimLibException">wimlib does not return WIMLIB_ERR_SUCCESS.</exception>
        public static Wim OpenWim(string wimFile, WimLibOpenFlags openFlags, WimLibCallback callback = null, object userData = null)
        {
            WimLibErrorCode ret = WimLibNative.OpenWim(wimFile, openFlags, out IntPtr wimPtr);

            WimLibException.CheckWimLibError(ret);

            Wim wim = new Wim(wimPtr);

            if (callback != null)
            {
                wim.RegisterCallback(callback, userData);
            }

            return(wim);
        }