mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 15:43:01 +00:00 
			
		
		
		
	Change os/perm-str to os/perm-string.
This commit is contained in:
		| @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. | ||||
| ## Unreleased - ??? | ||||
| - Add os/umask | ||||
| - Add os/perm-int | ||||
| - Add os/perm-str | ||||
| - Add os/perm-string | ||||
|  | ||||
| ## 1.8.1 - 2020-03-31 | ||||
| - Fix bugs for big endian systems | ||||
|   | ||||
| @@ -1303,7 +1303,7 @@ static const JanetReg os_cfuns[] = { | ||||
|         "os/chmod", os_chmod, | ||||
|         JDOC("(os/chmod path mode)\n\n" | ||||
|              "Change file permissions, where mode is a permission string as returned by " | ||||
|              "os/perm-str, or an integer as returned by os/perm-int. " | ||||
|              "os/perm-string, or an integer as returned by os/perm-int. " | ||||
|              "When mode is an integer, it is interpreted as a Unix permission value, best specified in octal, like " | ||||
|              "8r666 or 8r400. Windows will not differentiate between user, group, and other permissions, and thus will combine all of these permissions. Returns nil.") | ||||
|     }, | ||||
| @@ -1445,8 +1445,8 @@ static const JanetReg os_cfuns[] = { | ||||
|              "Returns an absolute path as a string. Will raise an error on Windows.") | ||||
|     }, | ||||
|     { | ||||
|         "os/perm-str", os_permission_string, | ||||
|         JDOC("(os/perm-str int)\n\n" | ||||
|         "os/perm-string", os_permission_string, | ||||
|         JDOC("(os/perm-string int)\n\n" | ||||
|              "Convert a Unix octal permission value from a permission integer as returned by os/stat " | ||||
|              "to a human readable string, that follows the formatting " | ||||
|              "of unix tools like ls. Returns the string as a 9 character string of r, w, x and - characters. Does not " | ||||
|   | ||||
| @@ -8,7 +8,8 @@ | ||||
|  | ||||
| (defn assert | ||||
|   "Override's the default assert with some nice error handling." | ||||
|   [x e] | ||||
|   [x &opt e] | ||||
|   (default e "assert error") | ||||
|   (++ num-tests-run) | ||||
|   (when x (++ num-tests-passed)) | ||||
|   (if x | ||||
|   | ||||
| @@ -194,4 +194,18 @@ | ||||
| (assert (deep= @[] (accumulate2 + [])) "accumulate2 2") | ||||
| (assert (deep= @[] (accumulate 0 + [])) "accumulate 2") | ||||
|  | ||||
| # Perm strings | ||||
|  | ||||
| (assert (= (os/perm-int "rwxrwxrwx") 8r777) "perm 1") | ||||
| (assert (= (os/perm-int "rwxr-xr-x") 8r755) "perm 2") | ||||
| (assert (= (os/perm-int "rw-r--r--") 8r644) "perm 3") | ||||
|  | ||||
| (assert (= (band (os/perm-int "rwxrwxrwx") 8r077) 8r077) "perm 4") | ||||
| (assert (= (band (os/perm-int "rwxr-xr-x") 8r077) 8r055) "perm 5") | ||||
| (assert (= (band (os/perm-int "rw-r--r--") 8r077) 8r044) "perm 6") | ||||
|  | ||||
| (assert (= (os/perm-string 8r777) "rwxrwxrwx") "perm 7") | ||||
| (assert (= (os/perm-string 8r755) "rwxr-xr-x") "perm 8") | ||||
| (assert (= (os/perm-string 8r644) "rw-r--r--") "perm 9") | ||||
|  | ||||
| (end-suite) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose