Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-compiler-and-rts
compiler
Commits
12b588d4
Commit
12b588d4
authored
Oct 01, 2001
by
Ronny Wichers Schreur
🏢
Browse files
moved system independent code to new module "filesystem"
parent
e28bc780
Changes
3
Hide whitespace changes
Inline
Side-by-side
main/Windows/CoclSystemDependent.icl
View file @
12b588d4
...
...
@@ -2,7 +2,10 @@
implementation
module
CoclSystemDependent
import
StdEnv
//import code from "cDirectory.obj", library "directory_library" // Windows
// import for filesystem
import
code
from
"cDirectory.obj"
,
library
"directory_library"
// Windows
from
filesystem
import
ensureDirectoryExists
PathSeparator
:==
';'
...
...
@@ -20,28 +23,7 @@ SystemDependentInitialIO
ensureCleanSystemFilesExists
::
!
String
!*
Files
->
(!
Bool
,
!*
Files
)
// returned bool: now there is such a subfolder
ensureCleanSystemFilesExists
path
env
=
(
False
,
env
)
/* # path_c_string = path +++ "\0"
(err_code, env) = createDirectoryC path_c_string env
= (err_code==M_NoDirError || err_code==M_AlreadyExists, env)
*/
createDirectoryC
::
!
String
!*
env
->
(!
Int
,
!*
env
)
createDirectoryC
_
_
=
code
{
ccall
createDirectoryC
"S:I:A"
}
// createDirectoryC returns the following error codes:
M_NoDirError
:==
0
M_OtherDirError
:==
-1
M_DoesntExist
:==
-2
M_BadName
:==
-3
M_NotEnoughSpace
:==
-4
M_AlreadyExists
:==
-5
M_NoPermission
:==
-6
=
ensureDirectoryExists
path
env
set_compiler_id
::
Int
->
Int
set_compiler_id
compiler_id
=
compiler_id
main/filesystem.dcl
0 → 100644
View file @
12b588d4
/*
module owner: Ronny Wichers Schreur
This module contains some file functions that are not in StdEnv
It uses the object file from Directory 1.1, but with a different
(stripped down) interface.
*/
definition
module
filesystem
from
StdFile
import
FileSystem
,
Files
// return last modified time (local time) as "yyyymmddhhmmss" or "" on error
fmodificationtime
::
{#
Char
}
!*
env
->
(!{#
Char
},
!*
env
)
|
FileSystem
env
// create a directory, if it doesn't exist already
ensureDirectoryExists
::
!{#
Char
}
!*
env
->
(!
Bool
,
!*
env
)
|
FileSystem
env
main/filesystem.icl
0 → 100644
View file @
12b588d4
/*
module owner: Ronny Wichers Schreur
This module contains some file functions that are not in StdEnv
It uses the object file from Directory 1.1, but with a different
(stripped down) interface.
*/
implementation
module
filesystem
import
StdEnv
// the import code is in CoclSystemDependent, because it is system dependent
// BEGIN copied from Directory.icl
createDirectoryC
::
!
String
!*
env
->
(!
Int
,
!*
env
)
createDirectoryC
_
_
=
code
{
ccall
createDirectoryC
"S:I:A"
}
findSingleFileC
::
!
String
!*
env
->
(!
ErrCode
,
!*
env
)
findSingleFileC
_
_
=
code
{
ccall
findSingleFileC
"S:I:A"
}
::
ErrCode
:==
Int
// <>0 <=> error
::
DateTimeTuple
:==
(!
DateTuple
,
!
TimeTuple
)
::
DateTuple
:==
(!
Int
,
!
Int
,
!
Int
,
!
Int
)
::
TimeTuple
:==
(!
Int
,
!
Int
,
!
Int
)
getCommonFileInfoC
::
!
Bool
!*
env
->
(!(!
String
,
!(!
Int
,
!
Int
),
!
DateTimeTuple
,
!
Bool
,
!
Bool
),
!*
env
)
getCommonFileInfoC
_
_
=
code
{
ccall
getCommonFileInfoC
"I:VSIIIIIIIIIII:A"
}
// createDirectoryC returns the following error codes:
M_NoDirError
:==
0
M_OtherDirError
:==
-1
M_DoesntExist
:==
-2
M_BadName
:==
-3
M_NotEnoughSpace
:==
-4
M_AlreadyExists
:==
-5
M_NoPermission
:==
-6
// END copied from Directory.icl
// return last modified time (local time) as "yyyymmddhhmmss" or "" on error
fmodificationtime
::
{#
Char
}
!*
env
->
(!{#
Char
},
!*
env
)
|
FileSystem
env
fmodificationtime
path
env
#
(
result
,
env
)
=
findSingleFileC
(
path
+++
"
\0
"
)
env
|
result
<>
0
=
(
""
,
env
)
#
((_,
_,
lastModifiedTuple
,
_,
_),
env
)
=
getCommonFileInfoC
False
env
=
(
dateTimeTupleToString
lastModifiedTuple
,
env
)
dateTimeTupleToString
::
DateTimeTuple
->
{#
Char
}
dateTimeTupleToString
((
year
,
month
,
day
,
_),
(
hours
,
minutes
,
seconds
))
=
string
4
year
+++
string
2
month
+++
string
2
day
+++
string
2
hours
+++
string
2
minutes
+++
string
2
seconds
where
string
::
!
Int
!
Int
->
{#
Char
}
string
minSize
n
=
pad
(
minSize
-
size
s
)
+++
s
where
s
=
toString
n
pad
::
Int
->
{#
Char
}
pad
n
|
n
>
0
=
createArray
n
'0'
// otherwise
=
""
ensureDirectoryExists
::
!{#
Char
}
!*
env
->
(!
Bool
,
!*
env
)
|
FileSystem
env
// returned bool: now there is such a subfolder
ensureDirectoryExists
path
env
#
path_c_string
=
path
+++
"
\0
"
(
err_code
,
env
)
=
createDirectoryC
path_c_string
env
=
(
err_code
==
M_NoDirError
||
err_code
==
M_AlreadyExists
,
env
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment