Skip to content

Instantly share code, notes, and snippets.

@reasonset
Created May 4, 2016 16:05
Show Gist options
  • Save reasonset/c748c8352cf82cb099ae969811671ffe to your computer and use it in GitHub Desktop.
Save reasonset/c748c8352cf82cb099ae969811671ffe to your computer and use it in GitHub Desktop.
clone cdrdao (Linux), mount Daemon Tools (Windows)
#!/usr/bin/zsh
# This is intend to generate image with cdrdao in Linux and mount with DAEMON Tools in Windows.
# If you give -r as first argument, This program reads disc with cdrdao.
# Any prefix means file name without extension.
# For example, "foo/bar" means foo/bar.{bin,toc,cue}
# Usage:
# mk-windows-virtual-disc.zsh <existing_image_prefix> <output_prefix>
# mk-windows-virtual-disc.zsh -r <linux_output_prefix> <windows_output_prefix>
if [[ $1 == "-r" ]]
then
readcd=true
shift
fi
linuxout="$1"
windowsout="$2"
if [[ readcd == true ]]
then
if [[ ! -e "${linuxout:h}" ]]
then
mkdir -pv "${linuxout:h}"
fi
cdrdao read-cd --read-raw --datafile "$linuxout".bin --driver generic-mmc-raw "$linuxout".toc
fi
if [[ ! -e "${windowsout:h}" ]]
then
mkdir -pv "${windowsout:h}"
fi
toc2cue "$linuxout".toc "$windowsout".cue
sed -i -e "1s/.*/FILE ${windowsout:t}.bin BINARY/" "$windowsout".cue
dd if="$linuxout".bin of="$windowsout".bin conv=swab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment