Created
August 17, 2012 10:18
-
-
Save akiradeveloper/3377757 to your computer and use it in GitHub Desktop.
memtouchの結果
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 動作: | |
| 1. ファイルが存在するならば, 単にtouchして終わる. | |
| 2. 絶対パスを計算する. | |
| 3. /dev/shm/絶対パス にファイルを作る. | |
| 4. ファイルから/dev/shm以下のファイルにsymlinkする. | |
| ちゃんと動いてそうなことを確認. | |
| akira@Paptimus> ./memtouch /tmp/hige ~/dotfiles/user/pre-build/bin | |
| akira@Paptimus> ls -l /tmp/hige ~/dotfiles/user/pre-build/bin | |
| lrwxrwxrwx 1 akira sudo 17 Aug 17 19:15 /tmp/hige -> /dev/shm/tmp/hige | |
| akira@Paptimus> ./memtouch hoge ~/dotfiles/user/pre-build/bin | |
| akira@Paptimus> ls -l hoge ~/dotfiles/user/pre-build/bin | |
| lrwxrwxrwx 1 akira sudo 52 Aug 17 19:15 hoge -> /dev/shm/home/akira/dotfiles/user/pre-build/bin/hoge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| akira@Paptimus> cat memtouch ~/dotfiles/user/pre-build/bin | |
| #!/usr/bin/env ruby | |
| require "pathname" | |
| MEMFS_DIR="/dev/shm" | |
| file = ARGV[0] | |
| if Pathname(file).exist? | |
| system("touch #{file}") | |
| exit | |
| end | |
| abspath = nil | |
| if Pathname(file).absolute? | |
| abspath = file | |
| elsif | |
| abspath = File.join(Pathname.pwd, file) | |
| end | |
| realfilepath = File.join(MEMFS_DIR, abspath) | |
| system "mkdir -p #{File.dirname(realfilepath)}" | |
| system "touch #{realfilepath}" | |
| system "ln -s #{realfilepath} #{file}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment