Skip to content

Commit

Permalink
fix create directory chain. close #3
Browse files Browse the repository at this point in the history
  • Loading branch information
doublefint committed Nov 24, 2016
1 parent 83e56db commit 4f225d2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
12 changes: 10 additions & 2 deletions sc.all.cls
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,20 @@ ClassMethod import(qspec = "cku-d", ByRef err = "", recurse = 1, ByRef loaded =
/// Translate ( codename ) into ( filename )
ClassMethod filename(code)
{
#define log(%dir,%sc) w !, "mkdir ", %dir, " ", %sc
s wd = ..workdir()
d:'##class(%File).DirectoryExists( wd ) ##class(%File).CreateDirectoryChain( wd )
if '##class(%File).DirectoryExists( wd ) {
s sc = ##class(%File).CreateDirectoryChain( wd )
$$$log(wd,sc)
}
s filename = ##class(%File).NormalizeFilename( code, wd )
#; for *.dfi filename can contain folders
s path = ##class(%File).GetDirectory(filename)
d:'##class(%File).DirectoryExists( path ) ##class(%File).CreateDirectoryChain( path )
if '##class(%File).DirectoryExists( path ) {
s sc=##class(%File).CreateDirectoryChain(path)
$$$log(path,sc)
}

Q filename
}

Expand Down
22 changes: 19 additions & 3 deletions sc.all.sub.cls
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,32 @@ Class sc.all.sub Extends sc.all
/// etc
ClassMethod filename(code)
{
#define log(%dir,%sc) w !, "mkdir ", %dir, " ", sc

s wd = ..workdir()

if '##class(%File).DirectoryExists( wd ) {
s sc = ##class(%File).CreateDirectoryChain( wd )
$$$log(wd,sc)
}

s ext = $p( code, ".", * ), ext = $zcvt( ext, "l" )
#; for each type - different directory
s wd = ..workdir() s:ext'="" wd = ##class(%File).NormalizeDirectory( ext, wd )
d:'##class(%File).DirectoryExists( wd ) ##class(%File).CreateDirectoryChain( wd )

s:ext'="" wd = ##class(%File).NormalizeDirectory( ext, wd )
if '##class(%File).DirectoryExists( wd ) {
s sc = ##class(%File).CreateDirectoryChain( wd )
$$$log(wd,sc)
}

s filename = ##class(%File).NormalizeFilename( code, wd )
#; for *.dfi filename can contain folders
if ext = "dfi" {
s path = ##class(%File).GetDirectory( filename )
d:'##class(%File).DirectoryExists( path ) ##class(%File).CreateDirectoryChain( path )
if '##class(%File).DirectoryExists( path ) {
s sc = ##class(%File).CreateDirectoryChain( path )
$$$log(path,sc)
}
}
Q filename
}
Expand Down

0 comments on commit 4f225d2

Please sign in to comment.