It is currently Wed Jun 19, 2013 6:14 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Create Folder-Tree
PostPosted: Sun Apr 15, 2012 9:18 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 20, 2008 2:12 am
Posts: 650
Location: Cologne, Germany
Hi there,

as CreateDirectory does not create a folder tree, I hacked a small function to do this...
Should be self explanatory.

Code:
Procedure   Create_FolderTree(dest$)
  If Right(dest$,1) <> "/" : dest$ + "/" : EndIf
  If FileSize(dest$) = -1
    Temp$ = ""
    For i = 1 To CountString(dest$,"/")
      temp$ + StringField(dest$,i,"/") + "/"
      If FileSize(Temp$) = -1
        CreateDirectory(Temp$)
      EndIf
    Next i
  EndIf
EndProcedure

_________________
Regards,
JamiroKwai

---
5.10-x64/x86 - MacBook Pro, Mountain Lion
My Blog (German): http://www.quadworks.de


Last edited by jamirokwai on Tue Apr 17, 2012 11:17 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Create Folder-Tree
PostPosted: Mon Apr 16, 2012 4:13 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 22, 2003 2:51 am
Posts: 734
Location: Canada
Hello,

This a cross-platform solution :

Code:
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : BuiltPathDirectory
; File Name : BuiltPathDirectory.pb
; File version: 1.1.0
; Programming : OK
; Programmed by : Guimauve
; Date : 29-04-2008
; Last Update : 15-04-2012
; PureBasic code : 4.60
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Procedure.b BuiltPathDirectory(Path.s)
 
  CompilerSelect #PB_Compiler_OS
     
    CompilerCase #PB_OS_Windows
      PathSep.s = "\"
     
    CompilerCase #PB_OS_Linux
      PathSep.s = "/"
     
    CompilerCase #PB_OS_MacOS
      PathSep.s = "/"
     
  CompilerEndSelect
 
  DirectoryQty = CountString(Path, PathSep) + 1
 
  For Index = 1 To DirectoryQty
   
    Directory.s = Directory + StringField(Path, Index, PathSep) + PathSep
   
    If FileSize(Directory) = -1
      CreateDirectory(Directory)
    EndIf
   
  Next
 
  If FileSize(Directory) = -2
    Success.b = #True
  Else
    Success = #False
  EndIf
 
  ProcedureReturn Success
EndProcedure

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<


Best regards
Guimauve


Top
 Profile  
 
 Post subject: Re: Create Folder-Tree
PostPosted: Mon Apr 16, 2012 5:42 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Mar 24, 2004 11:04 pm
Posts: 761
Location: Seattle, USA
Doesn't Windows accept both / and \ as path delimiters ?

_________________
Win7 x64, PB x86


Top
 Profile  
 
 Post subject: Re: Create Folder-Tree
PostPosted: Mon Apr 16, 2012 8:19 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Sep 20, 2004 7:12 am
Posts: 297
Location: Hell
jamirokwai wrote:
Hi there,
Should be self explanatory.


If this was your goal, you shouldn't use german variablenames. (And where does zielort$ come from?)

_________________
Please, don't bump bug reports!
(Let them rest in peace...)


Top
 Profile  
 
 Post subject: Re: Create Folder-Tree
PostPosted: Tue Apr 17, 2012 11:18 am 
Offline
Enthusiast
Enthusiast

Joined: Tue May 20, 2008 2:12 am
Posts: 650
Location: Cologne, Germany
HeX0R wrote:
jamirokwai wrote:
Hi there,
Should be self explanatory.


If this was your goal, you shouldn't use german variablenames. (And where does zielort$ come from?)


Oh, yeah :-)

For your convenience, changed to dest$ ...
And thanks for the hint, regarding the error with zielort$ ...

_________________
Regards,
JamiroKwai

---
5.10-x64/x86 - MacBook Pro, Mountain Lion
My Blog (German): http://www.quadworks.de


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Poshu, User_Russian and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye