Esempio n. 1
0
        public static bool SpawnSync(string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out string stdout, out string stderr, out int exit_status)
        {
            IntPtr native_stdout, native_stderr, error;
            IntPtr native_dir = Marshaller.StringToPtrGStrdup(working_directory);

            IntPtr[] native_argv           = Marshaller.StringArrayToNullTermPointer(argv);
            IntPtr[] native_envp           = Marshaller.StringArrayToNullTermPointer(envp);
            SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper(child_setup);
            bool result;

            if (Global.IsWindowsPlatform)
            {
                result = g_spawn_sync(native_dir, native_argv, native_envp, (int)flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
            }
            else
            {
                result = g_spawn_sync(native_dir, native_argv, native_envp, (int)flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
            }

            Marshaller.Free(native_dir);
            Marshaller.Free(native_argv);
            Marshaller.Free(native_envp);
            stdout = Marshaller.PtrToStringGFree(native_stdout);
            stderr = Marshaller.PtrToStringGFree(native_stderr);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(result);
        }
        static public string EscapeText(string s)
        {
            if (s == null)
            {
                return(String.Empty);
            }

            IntPtr native = Marshaller.StringToPtrGStrdup(s);
            string result = Marshaller.PtrToStringGFree(g_markup_escape_text(native, -1));

            Marshaller.Free(native);
            return(result);
        }
Esempio n. 3
0
        public bool LoadFromDataDirs(string file, out string full_path, KeyFileFlags flags)
        {
            IntPtr error;
            IntPtr native_full_path;
            IntPtr native_file = Marshaller.StringToPtrGStrdup(file);
            bool   ret         = g_key_file_load_from_data_dirs(Handle, native_file, out native_full_path, (int)flags, out error);

            Marshaller.Free(native_file);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            full_path = Marshaller.PtrToStringGFree(native_full_path);
            return(ret);
        }
Esempio n. 4
0
        public string GetValue(string group_name, string key)
        {
            IntPtr error;
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);
            string ret = Marshaller.PtrToStringGFree(g_key_file_get_value(Handle, native_group_name, native_key, out error));

            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
Esempio n. 5
0
        public IOStatus ReadLine(out string str_return, out ulong terminator_pos)
        {
            IntPtr   native_string;
            UIntPtr  native_terminator_pos;
            IntPtr   error;
            IOStatus ret = (IOStatus)g_io_channel_read_line(Handle, out native_string, IntPtr.Zero, out native_terminator_pos, out error);

            terminator_pos = (ulong)native_terminator_pos;
            str_return     = null;
            if (ret == IOStatus.Normal)
            {
                str_return = Marshaller.PtrToStringGFree(native_string);
            }
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
Esempio n. 6
0
        public static bool SpawnCommandLineSync(string command_line, out string stdout, out string stderr, out int exit_status)
        {
            IntPtr error, native_stdout, native_stderr;
            IntPtr native_cmd = Marshaller.StringToPtrGStrdup(command_line);
            bool   result;

            if (Global.IsWindowsPlatform)
            {
                result = g_spawn_command_line_sync_utf8(native_cmd, out native_stdout, out native_stderr, out exit_status, out error);
            }
            else
            {
                result = g_spawn_command_line_sync(native_cmd, out native_stdout, out native_stderr, out exit_status, out error);
            }

            Marshaller.Free(native_cmd);
            stdout = Marshaller.PtrToStringGFree(native_stdout);
            stderr = Marshaller.PtrToStringGFree(native_stderr);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(result);
        }
Esempio n. 7
0
 static public string FormatSizeForDisplay(long size)
 {
     return(Marshaller.PtrToStringGFree(g_format_size_for_display(size)));
 }
Esempio n. 8
0
        static public string SizeForDisplay(long size)
        {
            string result = Marshaller.PtrToStringGFree(g_format_size_for_display(size));

            return(result);
        }
Esempio n. 9
0
        public string Print(bool type_annotate)
        {
            IntPtr str = g_variant_print(handle, type_annotate);

            return(Marshaller.PtrToStringGFree(str));
        }