Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-ide
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-ide
Commits
afeb04fe
Commit
afeb04fe
authored
Jul 11, 2018
by
John van Groningen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't use WinGetModulePath, WinFileExists and WinFileModifiedDate from the ObjectIO c code,
but call WinAPI functions directly
parent
10111f02
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
107 deletions
+106
-107
Win/Platform.dcl
Win/Platform.dcl
+4
-0
Win/Platform.icl
Win/Platform.icl
+57
-13
Win/UtilIO.icl
Win/UtilIO.icl
+45
-94
No files found.
Win/Platform.dcl
View file @
afeb04fe
...
...
@@ -22,3 +22,7 @@ wAbort :: !String !*World -> *World
onOSX
::
Bool
application_path
::
!
String
->
String
// same as applicationpath in StdSystem
get_module_file_name
::
!*
state
->
(!{#
Char
},!
Int
,!*
state
)
expand_8_3_names_in_path
::
!{#
Char
}
->
{#
Char
}
find_first_file_and_close
::
!{#
Char
}
->
(!
Bool
,!{#
Char
})
Win/Platform.icl
View file @
afeb04fe
...
...
@@ -4,9 +4,7 @@ import code from library "platform_kernel_library"
import
StdArray
,
StdEnum
,
StdList
,
StdClass
,
StdBool
,
StdMisc
import
ArgEnv
import
clCCall_12
import
logfile
,
set_return_code
from
ossystem
import
osApplicationpath
PlatformDependant
win
mac
:==
win
...
...
@@ -71,10 +69,42 @@ wAbort message world
//====
get_module_file_name
::
!*
state
->
(!{#
Char
},!
Int
,!*
state
)
get_module_file_name
state
=
get_module_file_name
261
state
where
get_module_file_name
::
!
Int
!*
state
->
(!{#
Char
},!
Int
,!*
state
)
get_module_file_name
file_name_size
state
#
(
file_name_size_result
,
file_name
,
state
)
=
GetModuleFileName
0
(
createArray
file_name_size
'\0'
)
state
|
file_name_size_result
<
file_name_size
=
(
file_name
,
file_name_size_result
,
state
)
#
(
last_error
,
state
)
=
GetLastError
state
|
last_error
==
0
/*ERROR_SUCCESS*/
=
(
file_name
,
file_name_size_result
,
state
)
|
last_error
==
122
/*ERROR_INSUFFICIENT_BUFFER*/
=
get_module_file_name
(
file_name_size
+
file_name_size
)
state
=
abort
"get_module_file_name failed"
GetModuleFileName
::
!
Int
!*{#
Char
}
!*
state
->
(!
Int
,!{#
Char
},!*
state
)
GetModuleFileName
hModule
file_name_buffer
state
=
code {
push_a
0
push_a
0
push_arraysize
CHAR
0
1
push_b
1
update_b
1
2
updatepop_b
0
1
ccall
GetModuleFileNameA@12
"PpsI:I:AA"
}
GetLastError
::
!*
state
->
(!
Int
,*
state
)
GetLastError
state
=
code {
ccall
GetLastError@0
"P:I:A"
}
inifilename
#
apppath
=
winGetModulePath
#
s
=
size
apppath
=:
apppath
%(
0
,
s
-4
)
+++.
"ini
\0
"
#
(
file_name_buffer
,
file_name_size
,
state
)
=
get_module_file_name
[]
=:
file_name_buffer
%
(
0
,
file_name_size
-4
)+++
"ini
\0
"
section
=:
"Paths
\0
"
tooltempkey
=:
"tooltemp
\0
"
...
...
@@ -157,7 +187,7 @@ find_data_file_name find_data
#
i
=
find_null_char_in_string
44
find_data
;
=
find_data
%
(
44
,
i
-1
);
find_first_file_and_close
::
!
String
->
(!
Bool
,!
String
);
find_first_file_and_close
::
!
{#
Char
}
->
(!
Bool
,!{#
Char
}
);
find_first_file_and_close
file_name
#
(
handle
,
find_data
)
=
FindFirstFile
file_name
;
|
handle
<>
(
-1
)
...
...
@@ -189,16 +219,30 @@ expand_8_3_names_in_path path_and_file_name
WinGetModulePath
::
{#
Char
}
WinGetModulePath
=
code
{
.inline
WinGetModulePath
ccall
WinGetModulePath
"-S"
.end
}
#
(
file_name_buffer
,
file_name_size
,
state
)
=
get_module_file_name
[]
=
file_name_buffer
%
(
0
,
file_name_size
-1
)
onOSX
::
Bool
onOSX
=
False
application_path
::
!
String
->
String
// same as applicationpath in StdSystem
application_path
fname
=
osApplicationpath
fname
application_path
fname
#
(
module_directory_path
,_)
=
get_module_directory_path
[]
=
module_directory_path
+++
fname
skip_file_name_at_end
::
!
Int
!{#
Char
}
->
Int
skip_file_name_at_end
i
s
|
i
>=
0
#
c
=
s
.[
i
]
|
c
==
'\\'
||
c
==
'/'
||
c
==
':'
=
i
=
skip_file_name_at_end
(
i
-1
)
s
=
i
get_module_directory_path
::
!*
state
->
(!{#
Char
},!*
state
)
get_module_directory_path
state
#
(
file_name_buffer
,
file_name_size
,
state
)
=
get_module_file_name
state
#
separator_index
=
skip_file_name_at_end
(
file_name_size
-1
)
file_name_buffer
// remove "\\\\?\\" ?
=
(
file_name_buffer
%
(
0
,
separator_index
),
state
)
Win/UtilIO.icl
View file @
afeb04fe
...
...
@@ -5,7 +5,8 @@ import code from library "util_io_kernel_lib" // GetShortPathNameA@12
import
StdArray
,
StdBool
,
StdClass
,
StdFile
,
StdList
,
StdTuple
,
StdString
import
UtilDate
import
StdPathname
,
Directory
from
Platform
import
DirSeparator
from
Platform
import
DirSeparator
,
get_module_file_name
,
expand_8_3_names_in_path
,
find_first_file_and_close
from
StdMisc
import
abort
FReadOnly
::
!{#
Char
}
!*
env
->
(!
Bool
,
!*
env
)
|
FileSystem
env
FReadOnly
path
files
...
...
@@ -27,57 +28,62 @@ FFileSize path files
=
((
False
,
0
),
files
)
=
((
True
,
fst
fi
.
pi_fileInfo
.
fileSize
),
files
)
WinGetModulePath
::
{#
Char
}
WinGetModulePath
=
code inline
{
ccall
WinGetModulePath
"-S"
}
WinFileModifiedDate
::
!{#
Char
}
->
(
!
Bool
,
!
Int
,
!
Int
,
!
Int
,
!
Int
,
!
Int
,
!
Int
)
WinFileModifiedDate
_
=
code inline
{
ccall
WinFileModifiedDate
"S-IIIIIII"
}
WinFileExists
::
!{#
Char
}
->
Bool
WinFileExists
_
=
code inline
{
ccall
WinFileExists
"S-I"
}
// Returns True if the file exists.
FExists
::
!
String
!
Files
->
(!
Bool
,
!
Files
)
FExists
name
files
=
(
WinFileExists
name
,
files
)
FExists
name
files
#!
(
file_exists
,_)
=
find_first_file_and_close
(
name
+++
"
\0
"
)
=
(
file_exists
,
files
)
ByteOffset_ftLastWriteTime
:==
20
;
Sizeof_FILETIME
:==
8
;
Sizeof_SYSTEMTIME
:==
16
;
/* Returns the last modification date of the indicated file.
*/
FModified
::
!
String
!
Files
->
(!
DATE
,
!
Files
);
FModified
name
files
=
(
daterec
,
files
);
where
(
exist
,
year
,
month
,
day
,
hour
,
minute
,
second
)
=
WinFileModifiedDate
name
;
daterec
=
{
exists
=
exist
,
yy
=
year
,
mm
=
month
,
dd
=
day
,
h
=
hour
,
m
=
minute
,
s
=
second
};
// Returns the last modification date of the indicated file.
FileTimeToSystemTime
::
!{#
Char
}
!*{#
Char
}
!*
state
->
(!
Int
,!{#
Char
},!*
state
);
FileTimeToSystemTime
fileTime
systemTime
state
=
code {
push_a
0
update_a
2
1
ccall
FileTimeToSystemTime@8
"Pss:I:AA"
}
/* Returns directory in which the indicated application resides.
*/
FModified
::
!
String
!
Files
->
(!
DATE
,
!
Files
);
FModified
name
files
#
(
ok
,
find_data
)
=
find_first_file_and_close
(
name
+++
"
\0
"
)
|
ok
#
last_write_time
=
find_data
%
(
ByteOffset_ftLastWriteTime
,
ByteOffset_ftLastWriteTime
+
Sizeof_FILETIME
-1
);
#
(
r
,
system_time
,
files
)
=
FileTimeToSystemTime
last_write_time
(
createArray
Sizeof_SYSTEMTIME
'\0'
)
files
;
|
r
<>
0
#
year
=
toInt
system_time
.[
0
]+(
toInt
system_time
.[
1
]<<
8
);
month
=
toInt
system_time
.[
2
]+(
toInt
system_time
.[
3
]<<
8
);
day
=
toInt
system_time
.[
6
]+(
toInt
system_time
.[
7
]<<
8
);
hour
=
toInt
system_time
.[
8
]+(
toInt
system_time
.[
9
]<<
8
);
minute
=
toInt
system_time
.[
10
]+(
toInt
system_time
.[
11
]<<
8
);
second
=
toInt
system_time
.[
12
]+(
toInt
system_time
.[
13
]<<
8
);
=
({
exists
=
True
,
yy
=
year
,
mm
=
month
,
dd
=
day
,
h
=
hour
,
m
=
minute
,
s
=
second
}
,
files
);
=
({
exists
=
True
,
yy
=
0
,
mm
=
0
,
dd
=
0
,
h
=
0
,
m
=
0
,
s
=
0
},
files
);
=
({
exists
=
False
,
yy
=
0
,
mm
=
0
,
dd
=
0
,
h
=
0
,
m
=
0
,
s
=
0
},
files
);
onOSX
::
Bool
onOSX
=
False
// Returns directory in which the indicated application resides.
FStartUpDir
::
!
String
!
Files
->
(!
String
,
!
Files
);
FStartUpDir
_
files
=
(
expand_8_3_names_in_path
name
,
files
);
where
name
=
RemoveFileName
WinGetModulePath
;
name
=
RemoveFileName
get_module_path
;
get_module_path
::
{#
Char
}
get_module_path
#
(
file_name_buffer
,
file_name_size
,
state
)
=
get_module_file_name
[]
=
file_name_buffer
%
(
0
,
file_name_size
-1
)
GetFullApplicationPath
::
!*
Files
->
({#
Char
},
*
Files
);
GetFullApplicationPath
files
=
FStartUpDir
""
files
;
=
FStartUpDir
""
files
;
RemoveFileName
::
!
String
->
String
;
RemoveFileName
path
...
...
@@ -95,11 +101,9 @@ LastColon s i
=
(
True
,
i
);
=
LastColon
s
(
dec
i
);
//-- expand_8_3_names_in_path
FindFirstFile
::
!
String
->
(!
Int
,!
String
);
FindFirstFile
file_name
#
find_data
=
createArray
3
18
'\0'
;
#
find_data
=
createArray
3
20
'\0'
;
#
handle
=
FindFirstFile_
file_name
find_data
;
=
(
handle
,
find_data
);
...
...
@@ -124,38 +128,6 @@ find_data_file_name find_data
#
i
=
find_null_char_in_string
44
find_data
;
=
find_data
%
(
44
,
i
-1
);
find_first_file_and_close
::
!
String
->
(!
Bool
,!
String
);
find_first_file_and_close
file_name
#
(
handle
,
find_data
)
=
FindFirstFile
file_name
;
|
handle
<>
(
-1
)
#
r
=
FindClose
handle
;
|
r
==
r
=
(
True
,
find_data
);
=
(
False
,
find_data
);
=
(
False
,
""
);
find_last_backslash_in_string
i
s
|
i
<
0
=
(
False
,
-1
);
|
s
.[
i
]==
'\\'
=
(
True
,
i
);
=
find_last_backslash_in_string
(
i
-1
)
s
;
expand_8_3_names_in_path
::
!{#
Char
}
->
{#
Char
};
expand_8_3_names_in_path
path_and_file_name
#
(
found_backslash
,
back_slash_index
)
=
find_last_backslash_in_string
(
size
path_and_file_name
-1
)
path_and_file_name
;
|
not
found_backslash
=
path_and_file_name
;
#
path
=
expand_8_3_names_in_path
(
path_and_file_name
%
(
0
,
back_slash_index
-1
));
#
file_name
=
path_and_file_name
%
(
back_slash_index
+1
,
size
path_and_file_name
-1
);
#
path_and_file_name
=
path
+++
"
\\
"
+++
file_name
;
#
(
ok
,
find_data
)
=
find_first_file_and_close
(
path_and_file_name
+++
"
\0
"
);
|
ok
=
path
+++
"
\\
"
+++
find_data_file_name
find_data
;
=
path_and_file_name
;
//--
GetLongPathName
::
!
String
->
String
;
GetLongPathName
short_path
=
expand_8_3_names_in_path
short_path
;
// of analoog aan GetShortPathName kernelfunctie aanroepen...
...
...
@@ -197,24 +169,3 @@ where
=
code {
ccall
GetCurrentDirectoryA@8
"PIs:I"
}
//--
/*
import code from library "kernel_library"
Start = GetModuleFileName
MAX_PATH :== 260
GetModuleFileName :: (!Bool,!String)
GetModuleFileName
#! buf = createArray (MAX_PATH+1) '\0'
#! res = GetModuleFileName_ 0 buf MAX_PATH
= (res <> 0,buf)
where
GetModuleFileName_ :: !Int !String !Int -> !Int
GetModuleFileName_ handle buffer buf_length
= code {
ccall GetModuleFileNameA@12 "PIsI:I"
}
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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