diff --git a/src/include/limits.h b/src/include/limits.hpp similarity index 82% rename from src/include/limits.h rename to src/include/limits.hpp index 9dd58f00a..a0bcdb855 100644 --- a/src/include/limits.h +++ b/src/include/limits.hpp @@ -1,5 +1,5 @@ /* - LIMITS.h - hard wired safety limits + LIMITS.hpp - hard wired safety limits Copyright (C) Lumiera.org 2012, Hermann Vosseler @@ -20,13 +20,15 @@ */ -/** @file limits.h + +/** @file limits.hpp ** hard wired safety limits. - ** This tiny header defines some hard limits for indexing, counting, searching + ** Whenever some task is attempted until success, or in response to external input, + ** an arbitrary fixed constraint is imposed for indexing, counting, searching ** and similar ordinal operations. These limits are a protection against ordinal ** and index numbers insanely out-of dimension, like e.g. a symbolic ID with more ** than 1000 characters. Whenever an actual allocation is based on such ordinal values, - ** a tighter and more specific limitation will be enforced on a case by case base + ** a tighter and more specific limitation will be enforced on a case by case base. ** ** @see symbol-impl.cpp ** @see util::uNum @@ -39,5 +41,6 @@ #define LUMIERA_IDSTRING_MAX_RELEVANT 1000 #define LUMIERA_MAX_ORDINAL_NUMBER 1000 +#define LUMIERA_MAX_COMPETITION 100 #endif /*LUMIERA_LIMITS_H*/ diff --git a/src/lib/error-exception.cpp b/src/lib/error-exception.cpp index ee3a88472..573025bcc 100644 --- a/src/lib/error-exception.cpp +++ b/src/lib/error-exception.cpp @@ -85,6 +85,7 @@ namespace lumiera { LUMIERA_ERROR_DEFINE (WRONG_TYPE, "runtime type mismatch"); LUMIERA_ERROR_DEFINE (ITER_EXHAUST, "end of sequence reached"); LUMIERA_ERROR_DEFINE (CAPACITY, "predefined fixed storage capacity"); + LUMIERA_ERROR_DEFINE (SAFETY_LIMIT, "exceeding fixed internal safety limit"); LUMIERA_ERROR_DEFINE (INDEX_BOUNDS, "index out of bounds"); LUMIERA_ERROR_DEFINE (BOTTOM_VALUE, "invalid or NIL value"); LUMIERA_ERROR_DEFINE (UNCONNECTED, "missing connection"); diff --git a/src/lib/error.hpp b/src/lib/error.hpp index 745f33e34..29c538b1d 100644 --- a/src/lib/error.hpp +++ b/src/lib/error.hpp @@ -182,6 +182,7 @@ namespace lumiera { LUMIERA_ERROR_DECLARE (WRONG_TYPE); ///< runtime type mismatch LUMIERA_ERROR_DECLARE (ITER_EXHAUST); ///< end of sequence reached LUMIERA_ERROR_DECLARE (CAPACITY); ///< predefined fixed storage capacity + LUMIERA_ERROR_DECLARE (SAFETY_LIMIT); ///< exceeding fixed internal safety limit LUMIERA_ERROR_DECLARE (INDEX_BOUNDS); ///< index out of bounds LUMIERA_ERROR_DECLARE (BOTTOM_VALUE); ///< invalid or NIL value LUMIERA_ERROR_DECLARE (UNCONNECTED); ///< missing connection diff --git a/src/lib/stat/file.hpp b/src/lib/stat/file.hpp index 8e5f3f211..d6ae19fcc 100644 --- a/src/lib/stat/file.hpp +++ b/src/lib/stat/file.hpp @@ -91,7 +91,7 @@ namespace util { static std::string invoke (fs::path path) noexcept try { - return "\""+std::string{path}+"\""; + return "≺"+std::string{path}+"≻"; } catch(...) { return lib::meta::FAILURE_INDICATOR; } diff --git a/src/lib/symbol-impl.cpp b/src/lib/symbol-impl.cpp index a5247d9be..191d34adc 100644 --- a/src/lib/symbol-impl.cpp +++ b/src/lib/symbol-impl.cpp @@ -36,7 +36,7 @@ #include "lib/symbol.hpp" #include "lib/symbol-table.hpp" -#include "include/limits.h" +#include "include/limits.hpp" extern "C" { #include "lib/safeclib.h" } diff --git a/src/lib/test/temp-dir.hpp b/src/lib/test/temp-dir.hpp index 9bd2d3fac..8bd387791 100644 --- a/src/lib/test/temp-dir.hpp +++ b/src/lib/test/temp-dir.hpp @@ -33,16 +33,49 @@ #include "lib/error.hpp" #include "lib/nocopy.hpp" +#include "lib/random.hpp" #include "lib/stat/file.hpp" +#include "include/limits.hpp" +#include "lib/format-string.hpp" //#include //#include //#include +#include //#include namespace lib { namespace test{ + namespace error = lumiera::error; + + using util::_Fmt; + + namespace { + Literal TEMPFILE_PREFIX = "Lux"; + } + inline bool + has_perm (fs::path const& p, fs::perms permissionMask) + { + return (fs::status(p).permissions() & permissionMask) == permissionMask; + } + inline bool + can_read (fs::path const& p) + { + return has_perm (p, fs::perms::owner_read); + } + inline bool + can_write (fs::path const& p) + { + return has_perm (p, fs::perms::owner_write); + } + inline bool + can_exec (fs::path const& p) + { + return has_perm (p, fs::perms::owner_exec); + } + + /** * A RAII style temporary directory. */ @@ -52,14 +85,53 @@ namespace test{ fs::path loc_; public: - TempDir() = default; + TempDir() + : loc_{establishNewDirectory()} + { } + ~TempDir() + { + destroyTempDirectory(); + } + + + operator fs::path const& () const + { + return loc_; + } fs::path makeFile() { UNIMPLEMENTED ("make temporary file"); } + + + private: + static fs::path + establishNewDirectory() + { + auto tmpDir = fs::temp_directory_path(); + for (uint attempt=0; attempt diff --git a/src/stage/model/element-access.hpp b/src/stage/model/element-access.hpp index 3a5040dc3..9319631d7 100644 --- a/src/stage/model/element-access.hpp +++ b/src/stage/model/element-access.hpp @@ -55,7 +55,7 @@ #include "lib/error.hpp" #include "lib/nocopy.hpp" #include "lib/result.hpp" -#include "include/limits.h" +#include "include/limits.hpp" #include "lib/variant.hpp" #include "lib/meta/typelist-manip.hpp" #include "lib/access-casted.hpp" diff --git a/tests/library/test/temp-dir-test.cpp b/tests/library/test/temp-dir-test.cpp index 310eb308e..604afd322 100644 --- a/tests/library/test/temp-dir-test.cpp +++ b/tests/library/test/temp-dir-test.cpp @@ -32,6 +32,7 @@ //#include "lib/error.hpp" //#include "lib/util-foreach.hpp" #include "lib/format-cout.hpp" +#include "lib/test/diagnostic-output.hpp" //#include #include @@ -78,6 +79,24 @@ namespace test{ simpleUsage() { TempDir temp; +SHOW_EXPR(temp) +SHOW_EXPR(fs::path{temp}) +SHOW_EXPR(has_perm(temp, fs::perms::owner_read)); +SHOW_EXPR(has_perm(temp, fs::perms::owner_write)); +SHOW_EXPR(has_perm(temp, fs::perms::owner_exec)); +SHOW_EXPR(has_perm(temp, fs::perms::owner_all)); +SHOW_EXPR(has_perm(temp, fs::perms::group_read)); +SHOW_EXPR(has_perm(temp, fs::perms::group_write)); +SHOW_EXPR(has_perm(temp, fs::perms::group_exec)); +SHOW_EXPR(has_perm(temp, fs::perms::group_all)); +SHOW_EXPR(has_perm(temp, fs::perms::others_read)); +SHOW_EXPR(has_perm(temp, fs::perms::others_write)); +SHOW_EXPR(has_perm(temp, fs::perms::others_exec)); +SHOW_EXPR(has_perm(temp, fs::perms::others_all)); +SHOW_EXPR(has_perm(temp, fs::perms::all)); +SHOW_EXPR(can_read(temp)); +SHOW_EXPR(can_write(temp)); +SHOW_EXPR(can_exec(temp)); auto ff = temp.makeFile(); CHECK (fs::exists (ff)); CHECK (fs::is_empty (ff)); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 3808d7364..4b80f72cf 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -57248,19 +57248,148 @@ - + - + + + + + + + + + +

+ Verstehe die Doku so: wenn directory existiert ⟹ kein Fehler +

+ + +
+
+ + + + + + + + + if -1 is returned, no directory shall be created. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ ja man könnte.... aber welches Risiko soll damit adressiert werden (da es ja nun doch zusätzliche Kosten in der Form von Nonportabilität beinhaltet)? Immerhin ist die ganze Sache mit den Zufallszahlen sowiso mehr oder weniger professionelle Paranoia, denn 2^64 ~ 10^19 ist schon eine Menge +

+

+ ⟹ JAGNI +

+ + +
+
+
+ + + + + + + + +

+ die gestern implementierte Zufalls-Sequenz entropyGen.u64() +

+ + +
+
+ + + +
+
+ + + + + + +

+ Rückgabewert von create_directory +

+

+ + weitere Eigenschaften prüfen +

+ +
+ + + + + +
+ + + - + + + + + +