-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
81 changed files
with
4,444 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
* eol=lf | ||
*.vsh linguist-language=V text=auto | ||
v.mod linguist-language=Text | ||
* text=auto eol=lf | ||
*.bat eol=crlf | ||
|
||
**/*.v linguist-language=V | ||
**/*.vv linguist-language=V | ||
**/*.vsh linguist-language=V | ||
**/v.mod linguist-language=V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ build | |
.idea/ | ||
*.iml | ||
build | ||
src/touch/touch | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module pwd | ||
|
||
import os | ||
|
||
#include <pwd.h> | ||
#include <grp.h> | ||
|
||
struct C.passwd { | ||
pw_name &char | ||
pw_passwd &char | ||
pw_uid u32 | ||
pw_gid u32 | ||
pw_gecos &char | ||
pw_dir &char | ||
pw_shell &char | ||
} | ||
|
||
fn C.getpwuid(int) &C.passwd | ||
fn C.getgrgid(int) &C.passwd | ||
|
||
pub fn get_name_for_gid(gid int) !string { | ||
pwd := C.getgrgid(gid) | ||
unsafe { | ||
if isnil(pwd) { | ||
// Call succeeded but user not found | ||
if C.errno == 0 { | ||
return '' | ||
} | ||
return os.error_posix() | ||
} | ||
return cstring_to_vstring(pwd.pw_name) | ||
} | ||
} | ||
|
||
pub fn get_name_for_uid(uid int) !string { | ||
pwd := C.getpwuid(uid) | ||
unsafe { | ||
if isnil(pwd) { | ||
// Call succeeded but user not found | ||
if C.errno == 0 { | ||
return '' | ||
} | ||
return os.error_posix() | ||
} | ||
return cstring_to_vstring(pwd.pw_name) | ||
} | ||
} | ||
|
||
pub fn whoami() !string { | ||
uid := os.geteuid() | ||
if uid == -1 { | ||
return error('no user name') | ||
} | ||
return get_name_for_uid(uid) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module pwd | ||
|
||
import os | ||
|
||
pub fn get_name_for_gid(gid int) !string { | ||
return error('Not supported on Windows') | ||
} | ||
|
||
pub fn get_name_for_uid(uid int) !string { | ||
return error('Not supported on Windows') | ||
} | ||
|
||
pub fn whoami() !string { | ||
username := os.loginname() or { '' } | ||
if username == '' { | ||
return error('no user name') | ||
} | ||
return username | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.