blob: 6173692b07608893e873e31370f2faef0db89e14 [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#!/usr/bin/perl
2#
3# Copyright Statement:
4# --------------------
5# This software is protected by Copyright and the information contained
6# herein is confidential. The software may not be copied and the information
7# contained herein may not be used or disclosed except with the written
8# permission of MediaTek Inc. (C) 2005
9#
10# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
11# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
12# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
13# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
14# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
15# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
16# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
17# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
18# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
19# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
20# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
21# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
22#
23# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
24# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
25# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
26# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
27# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
28#
29# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
30# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
31# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
32# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
33# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
34#
35#
36#*****************************************************************************
37#*****************************************************************************
38##*
39##* Filename:
40##* ---------
41##* chmod.pl
42##*
43##* Project:
44##* --------
45##* MOLY
46##*
47##* Description:
48##* ------------
49##* This script change the permission of the files
50##*
51##* Author:
52##* -------
53##* kk Lin-Wang (mtk04222)
54##*
55##*============================================================================
56
57use strict;
58use warnings;
59
60($#ARGV < 1) && &Usage;
61
62# the mode
63my $mode = shift(@ARGV);
64
65# source files
66my @src = @ARGV;
67
68if ($mode =~ /^[0]+[0-7]{3}\b/)
69{
70 @src = glob("@src");
71 change_mode($mode,@src);
72}
73else
74{
75 &Usage;
76}
77
78#******************************************************************************
79## FUNCTION
80## change_mode
81## DESCRIPTION
82## change files permission
83## PARAMETER
84## $mode [IN] a number which format is 0XXX
85## $src [IN] an array of source files
86##
87## EXAMPLE
88## &change_mode(0644, @src);
89###******************************************************************************
90sub change_mode
91{
92 my ($cmode, @src) = @_ ;
93 foreach my $src_file (@src)
94 {
95 chmod(oct($cmode) ,$src_file) or die "[chmod.pl][Error:] chmod failed: $src_file $!";
96 }
97}
98
99
100#******************************************************************************
101## FUNCTION
102## Usage
103## DESCRIPTION
104## Display the manipulation of this script
105##******************************************************************************
106
107sub Usage
108{
109 warn <<"_END_OF_USAGE";
110Usage:
111 chmod.pl [permission][source[file1, file2,...]]
112Example:
113 perl chmod.pl 0644 foo.c foo.h
114 perl chmod.pl 0700 foo_folder/*.h
115
116_END_OF_USAGE
117 exit 1;
118}