Re: [AD] al_make_recursive_directory

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sat, 2010-10-23 at 16:10 +0200, Elias Pschernig wrote:
> On Sat, 2010-10-23 at 17:33 +1100, Peter Wang wrote:
> > 
> > There are numerous problems with the patch, which you will discover if
> > you try it ;)
> 
> Yes, it was just pseudo-code, I discovered as soon as I compiled, right
> after posting here... thought I had compiled before :P Anyway, was
> trivial to fix.
> 

Here's the real patch.

-- 
Elias Pschernig <elias.pschernig@xxxxxxxxxx>
diff --git a/src/fshook.c b/src/fshook.c
index 8100dd1..e5299a9 100644
--- a/src/fshook.c
+++ b/src/fshook.c
@@ -190,10 +190,24 @@ bool al_change_directory(const char *path)
 bool al_make_directory(const char *path)
 {
    const ALLEGRO_FS_INTERFACE *vt = al_get_fs_interface();
+   ALLEGRO_PATH *path1, *path2;
+   int i, n;
+   bool success;
+
    ASSERT(path);
    ASSERT(vt->fs_make_directory);
 
-   return vt->fs_make_directory(path);
+   path1 = al_create_path(path);
+   path2 = al_create_path(NULL);
+   n = al_get_path_num_components(path1);
+   for (i = 0; i < n; i++) {
+      al_append_path_component(path2, al_get_path_component(path1, i));
+      success = vt->fs_make_directory(al_path_cstr(path2, '/'));
+      if (!success) break;
+   }
+   al_destroy_path(path1);
+   al_destroy_path(path2);
+   return success;
 }
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/