多个 mdx 共享 同一个 mdd 的方法

平台:

  1. PC,GoldenDict 测试通过。
  2. Android
    • DictTango 同一文件夹只找到一个词典,失败。我猜是不是 .1.mdd 的格式有问题?其他词典的mdd的1.2.3都支持啊。
    • blueDictionary 成了。
    • plainDictionary 检测到一个文件夹内两个词典,查词时崩溃。失败。
    • 欧路 同一文件夹只找到一个词典。失败。

方法 1:将MDD解压成文件夹,与两个MDX同在。

缺点是复制时文件多,需要解压。

方法 2:复制成两份MDD,改名为各自的MDX名相同。

缺点是两倍占内存。

方法 3:如下图

详细步骤:

  1. 两个词典, a.mdxb.mdx 共享一份 a.mdd 多见于同一词典的多个衍生版本之间共享数据。
  2. MDX
    • 词典a.mdx:不变。
    • 词典b.mdx:改名成 a.1.mdx
  3. MDD:
    • 要共享的 a.mdd改成 a.1.mdd
  4. mdict 工具将空文件夹x打包成a.mdd

这样, 两个词典都以为有自己的重名相对应到同一个??.1.mdd

  1. 只不过一个词典自身名就是带??.1.mdx
  2. 另一个词典认为自己有2个mdd,共享的mdd是扩展的 .1.mdd

GoldenDict PC 可以这么玩,欢迎测试~


6 Likes

linux上有种东西叫符号链接,ln -s

1 Like

我的天,还可以这样卡bug呢,差点笑死:smile:

linux上我用过硬链接 ln a.mdd b.mdd
才知道符号链接也可以

2 Likes

安卓用不了。

咦?我再试试。

你这么一说,我觉得相对路径更好了,能访问父文件夹./../a.mp3 就更好了。

1 Like

羡慕Android一秒钟

Genius

安卓的/storage/emulated/0分区是不支持符号链接的

看不懂,记录一下。

ANDROID STORAGE:

On Android 5:

/sdcard >S> /storage/emulated/legacy >S> /mnt/shell/emulated/0
/mnt/shell/emulated >E> /data/media

On Android 6+:

# USER-ID of current user in case of multiple users, normally "0"

# for apps
# VIEW is one of "read" or "write" and /storage to VIEW bind mount is inside a separate mount namespace for every app
/sdcard >S> /storage/self/primary
/storage/self >B> /mnt/user/USER-ID
/mnt/user/USER-ID/primary >S> /storage/emulated/USER-ID
/storage/emulated >B> /mnt/runtime/VIEW/emulated
/mnt/runtime/VIEW/emulated >E> /data/media

# for services/daemons/processes in root namespace
/sdcard >S> /storage/self/primary
/storage >B> /mnt/runtime/default
/mnt/runtime/default/self/primary >S> mnt/user/0/primary
/mnt/user/0/primary >S> /storage/emulated/0
/storage/emulated >B> /mnt/runtime/default/emulated
/mnt/runtime/default/emulated >E> /data/media

>S> for symlink, >E> for emulated and >B> for bind mount

In short, /sdcard points to /data/media/0 through FUSE or sdcardfs emulation. This is to restrict unauthorized access of apps/processes to private media on SD card. Read Android's Storage Journey.

SYMLINKS:

Now /sdcard is not a real but emulated storage which represents a FAT/vFAT/FAT32 filesystem (for backward compatibility and permission management) which doesn't support symlinks (and other things including *NIX permissions and ioctls like FS_IOC_FIEMAP). So the Option 1 and 3 of yours won't work whether you create symlink directly on emulated storage or try to emulate the symlink already created on ext4.

BIND MOUNT:

This is the commonly used alternate of symlink for FAT family of filesystems. What you have tried in Option 2 should work. This is what apps like Apps2SD do. But there is again a constraint: mount namespace. You need to bind mount in global/root mount namespace so that the mount is visible to all apps:

su -mm -c 'mount -o bind "/data/sdext2/AppData/WhatsApp Media" "/sdcard/WhatsApp/Media"'

On Android 6+ this needs to be bind mounted on each VIEW (default, read, write) separately for all apps to work.

You can make it permanent by setting Mount Namespace Mode to Global in Magisk or by disabling Mount Namespace Separation in SuperSU. For details see this answer.

牛逼!思路清奇!

人如ID,楼主666!