|
10 | 10 | import com.couchbase.lite.support.Version; |
11 | 11 | import com.couchbase.lite.util.Log; |
12 | 12 | import com.couchbase.lite.util.StreamUtils; |
13 | | - |
14 | 13 | import com.couchbase.lite.util.Utils; |
15 | 14 | import com.fasterxml.jackson.databind.ObjectMapper; |
16 | 15 |
|
@@ -421,7 +420,14 @@ private String pathForName(String name) { |
421 | 420 | if ((name == null) || (name.length() == 0) || Pattern.matches(LEGAL_CHARACTERS, name)) { |
422 | 421 | return null; |
423 | 422 | } |
424 | | - name = name.replace('/', ':'); |
| 423 | + // NOTE: CouchDB allows forward slash as part of database name. |
| 424 | + // However, ':' is illegal character on Windows platform. |
| 425 | + // For Windows, substitute with period '.' |
| 426 | + if(isWindows()) { |
| 427 | + name = name.replace('/', '.'); |
| 428 | + }else{ |
| 429 | + name = name.replace('/', ':'); |
| 430 | + } |
425 | 431 | String result = directoryFile.getPath() + File.separator + name + Manager.DATABASE_SUFFIX; |
426 | 432 | return result; |
427 | 433 | } |
@@ -672,5 +678,15 @@ public Context getContext() { |
672 | 678 | protected boolean isAutoMigrateBlobStoreFilename() { |
673 | 679 | return this.options.isAutoMigrateBlobStoreFilename(); |
674 | 680 | } |
| 681 | + |
| 682 | + private static String OS = System.getProperty("os.name").toLowerCase(); |
| 683 | + |
| 684 | + /** |
| 685 | + * Check if platform is Windows |
| 686 | + */ |
| 687 | + @InterfaceAudience.Private |
| 688 | + private static boolean isWindows() { |
| 689 | + return (OS.indexOf("win") >= 0); |
| 690 | + } |
675 | 691 | } |
676 | 692 |
|
0 commit comments