Envelope-to: miura@localhost
Delivered-To: miura@samba.gr.jp
Delivered-To: samba-jp@samba.gr.jp
Date: Wed, 21 Jun 2000 23:44:00 +0900
From: Hiroshi MIURA <miura@blue.gr.jp>
Reply-To: samba-jp@samba.gr.jp
Subject: [samba-jp:06577] Re: HEX->EUC ܹԥġ
To: samba-jp@samba.gr.jp
In-Reply-To: Hiroshi MIURA's message of "Mon, 12 Jun 2000 23:18:06 +0900"	<E131V2S-00011A-00@triton2>
X-ML-Name: samba-jp
X-Mail-Count: 06577
X-MLServer: fml [fml 3.0.1 (20000326)]; post only (only members can post)
X-ML-Info: If you have a question, send e-mail with the body	"help" (without quotes) to the address samba-jp-ctl@samba.gr.jp;	help=<mailto:samba-jp-ctl@samba.gr.jp?body=help>
X-Mailer: cmail 2.60+19991208 on GNU Emacs 20.6.90.2 / Mule 4.1 (AOI)
User-Agent: EMIKO/1.13.9 (Euglena tripteris) FLIM/1.13.2 (Kasanui)
 APEL/10.2 Emacs/20.6.90 (i386-debian-linux-gnu) MULE/4.1 (AOI)
Mime-Version: 1.0 (generated by EMIKO 1.13.9 - "Euglena tripteris")
Content-Type: text/plain; charset=ISO-2022-JP
Precedence: bulk
X-UIDL: 0628ea0316a73ef67066ecd18b63911f

Ǥ

coding system=hexeucذܹԤġǤ¸ʸб
ޤǤȤꤢʤ˻ȤΤˤʤޤ

$ find /where/to/convert/ -exec hextoeuc {} \;
$ find /where/to/converted/  -type d -name '*:*' -exec rmdir {} \;

Τ褦ˤȤʥե뤬äʤ褦ˡ
äĤǤ


#! /usr/bin/perl 
#
# usage: hextoeuc [-l] </where/to/some/convert/filenames>
#  [</where/to/some/hardlink/path/>]
# default path = same path with original.
#
use Getopt::Std;
use File::stat;
require "jcode.pl";

getopts("dhl");
Show_Usage() if ($opt_h);

@list=@ARGV;
while($name=shift @list){
	$nname=chmbname($name);
	jcode::sjis2euc(*nname);

       next if ($name eq $nname);

       if ( -d $name) {
    	     $mode = stat($name)->mode; 
	     $mode &= 0777;
            if ($opt_d) {
		   printf "mkdir %s, %o\n",$nname, $mode;
	     } else {
		   mkdir $nname, $mode;
	     }
       } else {
  	   if ($opt_d) {
			print "link $name, $nname\n";
  	   } else {
		$res=link $name, $nname;
		if ($res) {
		   unlink $name unless ($opt_l);
		} else {
		   print "fail link: you have priviliges?\n";
	        }
	    
	  }
       }
}
exit;

sub chmbname{
	if (($n1,$hex,$n2)= ($_[0] =~ /^(.*)\:([0-9a-f][0-9a-f])(.*)/)){
		chmbname(sprintf("%s%c%s",$n1,hex($hex), $n2));
	}else{
		$_[0];
	}
}

sub Show_Usage{
	print "This is samba companion tool \n";
	print "Usage:";
	print "hextoeuc [-l] \</where/to/some/convert/\>\n";
	print "  default path = same path with original. \n";
exit;
}


-- 
YLUGå, TLUC, TLUG, JLAĿͲ, ACMز, 󥿡ͥåȳز
Correspondent of ChangeLog       hiroshi@ChangeLog.net
Project BLUE and BLACK           miura@blue.gr.jp
SAMBA development		 miura@samba.gr.jp  
Linux Kernel Hack Japan		 http://www.momokuri.org/
  MIURA, Hiroshi 	 hmiura@acm.org
