Re: Help on g_spwan_async




 Trsitan,

  I had done that before -- but the directory had a lof of other directories
and I was concerned with the application *hanging* deleting all the dirs and
files. I then decided to change to async call ( should have used threads
instead, but the lazy instinct called upon me :P)  -- Anyway, I changed the
code to what I had before ( which is what you have now, excet it uses
g_open_dir )

  Thanks for the replay


--- Tristan Van Berkom <vantr touchtunes com> wrote:
you could write a small `rm -rf` function
something like:

void rm(path) {
  DIR = opendir(path)
  while(readdir(DIR)) {
    if (is a dir) {
      rm(struct dirent.directory name); // call this same func
    } else {
      unlink();
    }
  }
}

I think this is all portable.
      -Tristan

Harring Figueiredo wrote:


Folks,

 I have the following code:

    exe_string = g_strdup_printf("%s %s", rm_cmd, path);
    g_print("Executing command: %s\n", exe_string);
    if ( g_shell_parse_argv(exe_string ,&i, &exe_cmd , &error) != TRUE) {
        *err = g_strdup(error->message);
        g_error_free(error);
        return FALSE;
    }
    ret_val = g_spawn_async_with_pipes(NULL, exe_cmd ,NULL,
            G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_SEARCH_PATH,
            NULL, NULL, &pid, NULL, NULL, NULL, &error);

  rm_cmd = "deltree /Y" and path= "I:\somepath\somedir"

 When I run the command on windowze, I can see the DOS console windows
poping
up and desapearing; however, the directory never gets deleted.

  IF I do an exact copy andpaty of the command that I output with g_print
above, the directory gets deleted.

  What am I doing wrong here ?

NOTE: I am using this code because I need to delete anentire directory
structure on Windows and the remove() calls is only working for files -- I
guess it has a bug reported on the remove(3) man pages.
If anyone has a better suggestion that the code above, please drop me a
line.

Note 2: compiled with mingwin gcc 2.95.3 (Windows binary from Tor's site.)

Thanks for any help.

Harring.

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]