0
|
1 |
#!/usr/bin/perl -w
|
|
2 |
# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
# which accompanies this distribution, and is available
|
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
#
|
|
9 |
# Initial Contributors:
|
|
10 |
# Nokia Corporation - initial contribution.
|
|
11 |
#
|
|
12 |
# Contributors:
|
|
13 |
#
|
|
14 |
# Description:
|
|
15 |
# USBinterop2
|
|
16 |
#
|
|
17 |
# AUTHOR: Steve Elliott
|
|
18 |
# DESCRIPTION: This is a simple utility to format a specified drive to the FAT format
|
|
19 |
#
|
|
20 |
#
|
|
21 |
# @ 2008
|
|
22 |
|
|
23 |
use Getopt::Long;
|
|
24 |
use Pod::Usage;
|
|
25 |
|
|
26 |
my $drive = "";
|
|
27 |
my $help = 0;
|
|
28 |
my $logfile = "";
|
|
29 |
|
|
30 |
# Error codes
|
|
31 |
my $KErrNone = 0; # No error - Test passed
|
|
32 |
my $KErrLogFile = -1; # Can't open log file
|
|
33 |
|
|
34 |
my %opts = ( 'drive=s' => \$drive,
|
|
35 |
'help!' => \$help,
|
|
36 |
'logfile=s'=> \$logfile);
|
|
37 |
|
|
38 |
GetOptions(%opts) || pod2usage(2);
|
|
39 |
pod2usage(-exitval => 1, -verbose => 2) if $help;
|
|
40 |
|
|
41 |
# we're starting
|
|
42 |
LogPrint("FAT format of device ".$drive.":\n");
|
|
43 |
|
|
44 |
open (INPUTPIPE,"| format ".$drive.": /FS:FAT") or exit $KErrLogFile;
|
|
45 |
|
|
46 |
close (INPUTPIPE) or exit $KErrLogFile;
|
|
47 |
|
|
48 |
LogPrint("Format complete\n");
|
|
49 |
|
|
50 |
# we're done, exit
|
|
51 |
print "\n* Done\n";
|
|
52 |
|
|
53 |
exit $KErrNone;
|
|
54 |
|
|
55 |
sub LogPrint
|
|
56 |
{
|
|
57 |
if ($logfile ne "")
|
|
58 |
{
|
|
59 |
open LOGFILE, ">>$logfile" or exit $KErrLogFile;
|
|
60 |
print LOGFILE @_;
|
|
61 |
close LOGFILE;
|
|
62 |
}
|
|
63 |
print @_;
|
|
64 |
}
|
|
65 |
|
|
66 |
######################################################################
|
|
67 |
|
|
68 |
__END__
|
|
69 |
|
|
70 |
=head1 NAME
|
|
71 |
|
|
72 |
formatdrive.pl - Formats a drive
|
|
73 |
|
|
74 |
=head1 SYNOPSIS
|
|
75 |
|
|
76 |
usage: formatdrive.pl [options]
|
|
77 |
|
|
78 |
=head1 OPTIONS
|
|
79 |
|
|
80 |
=over 0
|
|
81 |
|
|
82 |
=item --drive=<drive location>
|
|
83 |
|
|
84 |
The path to the drive to format.
|
|
85 |
|
|
86 |
=item --help=<file>
|
|
87 |
|
|
88 |
Displays this help.
|
|
89 |
|
|
90 |
=back
|
|
91 |
|
|
92 |
=head1 DESCRIPTION
|
|
93 |
|
|
94 |
This is a simple utility to format a specified drive to the FAT format
|
|
95 |
|
|
96 |
=cut
|