Commit Graph

11 Commits

Author SHA1 Message Date
Xavier Delaruelle
7fac70834a Remove fetch_hidden arg on getFilesInDirectory proc
Always return hidden directory entries.

Update both pure-Tcl and C version of getFilesInDirectory procedure
2020-08-10 09:00:17 +02:00
Xavier Delaruelle
e4a3b4443d lib: remove dup from getgroups result
`getgroups` system call may return a group list with duplicate entries,
so these duplicates need to be removed from result list. Use a *sort
then skip consecutive identical entries* strategy for this cleanup task.

Sort is performed with `qsort` system call therefore a
`+__Envmodules_IntCmp` function is introduced for it.
2020-08-10 08:06:09 +02:00
Xavier Delaruelle
452b3ffb25 lib: implement initStateUsergroups
Add function in libtclenvmodules to implement `initStateUsergroups` as a
Tcl command, which provides a more efficient way to retrieve current
groups of running process, rather forking to execute `id` external
binary.

Note that if current system does not support the `getgroups` system
call, only the primary group name of current user will be returned.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
11e6099aec lib: Implement initStateUsername
Add function in libtclenvmodules to implement `initStateUsername` as a
Tcl command, which provides a more efficient way to retrieve current
username, rather forking to execute `id` external binary.
2020-07-16 21:53:51 +02:00
Xavier Delaruelle
a5d0c0e3c5 lib: bump copyright year mention 2019-08-09 21:15:10 +02:00
Xavier Delaruelle
40477f8a3b lib: Tcl_GetBooleanFromObj already set err msg
No need to craft an error message when a non-boolean value is passed to
procedures as the Tcl_GetBooleanFromObj function already set the
accurate message when it returns non-OK.
2019-08-08 21:16:43 +02:00
Xavier Delaruelle
31eafcf860 lib: directly return res of Envmodules_Init last op 2019-08-06 13:24:48 +02:00
Xavier Delaruelle
afeae10ec0 Take .modulerc at modulepath root into account
When looking for modulefiles in enabled modulepaths, take .modulerc file
found at the root of a modulepath directory into account. Which means
these RC files are now evaluated like global rc files and can be used to
define module aliases targeting modulefiles stored in the underlying
file tree.

findModules procedure has been adapted to return any .modulerc file
found at the root of the directory. Code that look at modulepath root
has been adapted to use the getFilesInDirectory procedure or command.

A fetch_dotversion argument is added to the getFilesInDirectory Tcl
procedure and its libtclenvmodules counterpart. This argument is
disabled when looking at modulepath root content to avoid returning
eventual .version file stored there.

Shorthand version notation (ex: /1.0) cannot be used in a modulepath rc
file as a module name cannot be determined from this location.
2019-04-30 08:12:47 +02:00
Xavier Delaruelle
9b8e5981a7 Implement getFilesInDirectory in Tcl extension library
Add function in libtclenvmodules to implement getFilesInDirectory as a
command, which provides a more IO-optimized way than native Tcl commands
perform by avoiding specific additional queries to get hidden files like
.modulerc and .version. As a result 1 stat and 2 access syscalls are
saved per directory read.
2019-04-29 16:02:13 +02:00
Xavier Delaruelle
3b3534089e lib: adapt error report to support Tcl8.4
Add code to Tcl extension library to report error specifically when
built against Tcl8.4. This version of Tcl does not propose a
Tcl_ObjPrintf function, so the Tcl_AppendResult function is used instead
when the library is built against this version.
2019-04-29 16:02:13 +02:00
Xavier Delaruelle
3c360a9937 Introduce Modules Tcl extension library
Introduce Modules Tcl extension library (written in C) to extend Tcl
language in order to provide more optimized I/O commands than native Tcl
commands do.

This library first provides a 'readFile' command which performs an open,
read, close of a given modulefile to fetch its content. Compared to the
Tcl native open, read, close commands it saves 1 ioctl + 1 fcntl + N
lstat system calls per modulefile.
2019-04-29 15:56:23 +02:00