(n,mayBeJournal=false)
| 16368 | it makes names with a "-journal" suffix legal. |
| 16369 | */ |
| 16370 | const validateStorageName = function(n,mayBeJournal=false){ |
| 16371 | if( kvvfsIsPersistentName(n) ) return; |
| 16372 | const len = (new Blob([n])).size/*byte length*/; |
| 16373 | if( !len ) toss3(capi.SQLITE_MISUSE, "Empty name is not permitted."); |
| 16374 | let maxLen = cache.keySize - 1; |
| 16375 | if( cache.rxJournalSuffix.test(n) ){ |
| 16376 | if( !mayBeJournal ){ |
| 16377 | toss3(capi.SQLITE_MISUSE, |
| 16378 | "Storage names may not have a '-journal' suffix."); |
| 16379 | } |
| 16380 | }else if( ['-wal','-shm'].filter(v=>n.endsWith(v)).length ){ |
| 16381 | toss3(capi.SQLITE_MISUSE, |
| 16382 | "Storage names may not have a -wal or -shm suffix."); |
| 16383 | }else{ |
| 16384 | maxLen -= 8 /* so we have space for a matching "-journal" suffix */; |
| 16385 | } |
| 16386 | if( len > maxLen ){ |
| 16387 | toss3(capi.SQLITE_RANGE, "Storage name is too long. Limit =", maxLen); |
| 16388 | } |
| 16389 | let i; |
| 16390 | for( i = 0; i < len; ++i ){ |
| 16391 | const ch = n.codePointAt(i); |
| 16392 | if( ch<32 ){ |
| 16393 | toss3(capi.SQLITE_RANGE, |
| 16394 | "Illegal character ("+ch+"d) in storage name:",n); |
| 16395 | } |
| 16396 | } |
| 16397 | }; |
| 16398 | |
| 16399 | /** |
| 16400 | Create a new instance of the objects which go into |
no test coverage detected