| 108 | /************************************************************************/ |
| 109 | |
| 110 | static size_t GetCacheMax(size_t nCacheSize) |
| 111 | { |
| 112 | if (nCacheSize) |
| 113 | { |
| 114 | return nCacheSize; |
| 115 | } |
| 116 | |
| 117 | const char *pszCacheSize = CPLGetConfigOption("VSI_CACHE_SIZE", "25000000"); |
| 118 | GIntBig nMemorySize; |
| 119 | bool bUnitSpecified; |
| 120 | if (CPLParseMemorySize(pszCacheSize, &nMemorySize, &bUnitSpecified) != |
| 121 | CE_None) |
| 122 | { |
| 123 | CPLError( |
| 124 | CE_Failure, CPLE_IllegalArg, |
| 125 | "Failed to parse value of VSI_CACHE_SIZE. Using default of 25MB"); |
| 126 | nMemorySize = 25000000; |
| 127 | } |
| 128 | else if (static_cast<size_t>(nMemorySize) > |
| 129 | std::numeric_limits<size_t>::max() / 2) |
| 130 | { |
| 131 | nMemorySize = |
| 132 | static_cast<GIntBig>(std::numeric_limits<size_t>::max() / 2); |
| 133 | } |
| 134 | |
| 135 | return static_cast<size_t>(nMemorySize); |
| 136 | } |
| 137 | |
| 138 | /************************************************************************/ |
| 139 | /* VSICachedFile() */ |
no test coverage detected