Hyena.SafeUri.FilenameToUri C# (CSharp) Method

FilenameToUri() public static method

public static FilenameToUri ( string localPath ) : string
localPath string
return string
        public static string FilenameToUri(string localPath)
        {
            // TODO: replace with managed conversion to avoid marshalling
            IntPtr path_ptr = GLib.Marshaller.StringToPtrGStrdup (localPath);

            IntPtr uri_ptr = PlatformDetection.IsWindows
                ? g_filename_to_uri_utf8 (path_ptr, IntPtr.Zero, IntPtr.Zero)
                : g_filename_to_uri (path_ptr, IntPtr.Zero, IntPtr.Zero);

            GLib.Marshaller.Free (path_ptr);

            if (uri_ptr == IntPtr.Zero) {
                throw new ApplicationException ("Filename path must be absolute");
            }

            string uri = GLib.Marshaller.Utf8PtrToString (uri_ptr);
            GLib.Marshaller.Free (uri_ptr);

            return uri;
        }