// moveUnuseFileTex.mel // Mayonnaize Project // 2001 10/26 beta // $Id: moveUnuseFileTex.mel,v 1.2 2001/10/30 16:18:07 jagajin Exp jagajin $ global proc _moveUnuseFileTex() { string $s; string $fa[]; string $fileTexNames[]; string $fileTexNode[]; string $cur_prj_si_dir; // fileノードを探す。filenameを抜き出す。 $fileTexNode = `ls -type file`; for ( $i = 0; $i < `size $fileTexNode`; $i++) { $s = `getAttr ($fileTexNode[$i] + ".ftn")`; $fileTexNames[$i] = `substitute ".*sourceimages/" $s ""`; } //print $fileTexNames; // debug // デレクトリのファイルフェイズ int $flg; int $unuseCnt; $cur_prj_si_dir = `workspace -q -fn` + "/sourceimages/"; $fa = `getFileList -fld $cur_prj_si_dir`; $unuseCnt = 0; for ( $s in $fa) { //print $s; // debug $flg = 0; for ( $mayaFile in $fileTexNames ) { if ( `strcmp $s $mayaFile` == 0) { $flg = 1; } } if ( $flg == 0) { // $unuseCnt++; if ( $unuseCnt == 1) { $cmd = chDosPath("mkdir " + $cur_prj_si_dir + "unuse/"); //print ($cmd + "\n"); // debug system($cmd); } $from = $cur_prj_si_dir + $s; $from = chDosPath($from); $to = $cur_prj_si_dir + "unuse/" + $s; $to = chDosPath($to); $moveCmd = "move " + $from + " " + $to; //print ($moveCmd + "\n"); // debug system ($moveCmd); } } } global proc string chDosPath(string $from) { string $to; string $sa[]; int $tNum; $tNum = `tokenize $from "/" $sa`; $to = $sa[0]; for ( $i = 1; $i < $tNum ; $i++ ) { $to += "\\\\" + $sa[$i]; } return $to; } global proc moveUnuseFileTex() { string $cur_prj_si_dir; string $flist; $cur_prj_si_dir = `workspace -q -fn` + "/sourceimages/"; $currentFileList = `getFileList -fld $cur_prj_si_dir`; for ( $flist in $currentFileList ) { if ( `strcmp $flist "unuse"` != 0) { recursiveMoveUnuseFileTex($flist); } } } global proc recursiveMoveUnuseFileTex(string $checkFile) { string $fileList[]; string $cur_prj_si_dir; // カレントプロジェクトのsourceimageの絶対パス $cur_prj_si_dir = `workspace -q -fn` + "/sourceimages/"; // デレクトリだったら string $checkPath; $checkPath = ($cur_prj_si_dir + $checkFile + "/"); if ( `filetest -d $checkPath` == 1) { $fileList = `getFileList -fld ($checkPath)`; for ( $f in $fileList ) //print "call recursiveMoveUnuseFileTex \n"; // debug recursiveMoveUnuseFileTex( $checkFile + "/" + $f); return ; } // fi dir // マヤからファイルノードの一覧をゲットして string $fileTexNodes[]; string $fileTexNames[]; string $s; $fileTexNodes = `ls -type file`; for ( $i = 0; $i < `size $fileTexNodes`; $i++) { $s = `getAttr ($fileTexNodes[$i] + ".ftn")`; $fileTexNames[$i] = `substitute ".*sourceimages/" $s ""`; } // $checkFileが一致するかをテストする。 int $flg = 0; if ( `strcmp $checkFile "unuse"` == 0 ) { $flg = 1; } for ( $f in $fileTexNames ) { if ( `strcmp $f $checkFile` == 0) { $flg = 1; } // unuseデレクトリは例外 } // もし、一致しなかったらunuseデレクトリに移動。 if ( $flg == 0) { // その前にunuseデレクトリの制作 if ( `filetest -d ($cur_prj_si_dir+"unuse/")` == 0 ) { $cmd = chDosPath("mkdir " + $cur_prj_si_dir + "unuse/"); print ($cmd + "\n"); // debug system $cmd; } // サブデレクトリの制作 string $buf[]; //print ($checkFile + "\n" ); // debug $num = `tokenize $checkFile "/" $buf`; //print ("num = " + $num + "\n"); // debug if ( $num > 1 ) { // サブデレクトリが見つかった //print "hey!!\n"; // debug string $testDir = ""; for ( $n = 0; $n < $num -1 ; $n++) { $testDir += $buf[$n]; } $testDir = $cur_prj_si_dir + "unuse/" + $testDir + "/"; //print ($testDir + "\n" ); // debug if (`filetest -d $testDir` == 0 ) { $testDir = `chDosPath ($testDir)`; $cmd = ("mkdir " + $testDir); print ($cmd + "\n"); system $cmd; } } string $from, $to; $from = $cur_prj_si_dir + $checkFile; $from = chDosPath($from); $to = $cur_prj_si_dir + "unuse/" + $checkFile; $to = chDosPath($to); $moveCmd = "move " + $from + " " + $to; print ($moveCmd + "\n"); // debug system ($moveCmd); } // 終了。 return ; }