File: cdcontrol-erase

package info (click to toggle)
cdcontrol 1.90-1.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 160 kB
  • ctags: 16
  • sloc: sh: 944; makefile: 26
file content (130 lines) | stat: -rwxr-xr-x 4,065 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Erase a CD image already written to disk

if [ "${IMG_TYPE}" = "A" ];then
 if ! ls -F ${IMG_DIR}|grep '/' >/dev/null;then
  ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"'No one CD image was found, please select the read disk option on the main 
menu to create one. Press <Enter> to return." 0 0
  exit 1
 fi
elif [ "${IMG_TYPE}" = "D" ];then
 if ! ls -F ${IMG_DIR}|grep -v '/' >/dev/null;then
  ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"'No one CD image was found, please select the read disk option on the main 
menu to create one. Press <Enter> to return." 0 0
  exit 1
 fi
fi

# Create the temporary file that will be used to hold the return value
# of dialog menus
L_TMPFILE=`mktemp /tmp/fileXXXXXX`


# Erase a CD image
function cdcontrol_apaga_img {
 while ls $3|grep 'recorder'|grep 'busy' >/dev/null;do
  sleep 10
 done
 ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" --infobox $"Deleting $2..." 0 0
 rm -rf $1/$2
 if [ $? = 0 ];then
  clear
  ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --infobox $"'$2' sucessfully deleted. Press <Enter> to return..." 7 60
 else
  clear
  ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --infobox $"Unable to delete $2, press <Enter> to return..." 7 60
 fi
 exit 0
}


#------------------[ Inicio do menu de sele��o de Imagem ]--------------------------
if [ "${IMG_TYPE}" = "A" ];then
 ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" \
         --clear --title $"Delete a written CD image from memory" \
         --menu $"Use the up/down arrows and press <Enter>\n\
Press <Esc> or select 'Cancel' to exit:" 20 60 10 \
 `ls -F ${IMG_DIR} | grep '/' | sed -e s/"^"/"\""/ | \
  sed -e s/"\/$"/'\" \"\" \\ '/` 2>${L_TMPFILE}
elif [ "${IMG_TYPE}" = "D" ];then
 ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" \
         --clear --title $"Delete a written CD image" \
         --menu $"Use the up/down keys and press <Enter>\n\
Press <Esc> or select 'Cancel' to exit:" 20 60 10 \
 `ls -F ${IMG_DIR} | grep -v '/' | sed -e s/"^"/"\""/ | \
  sed -e s/"\.iso$"/'\.iso\" \"\" \\ '/` 2>${L_TMPFILE}
fi
 L_RETVAL=$?
 L_MAT_NAME=`cat ${L_TMPFILE}`
 rm -f ${L_TMPFILE} 

 case ${L_RETVAL} in
   1)
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"Canceled by user." 7 30
     exit 1
     ;;
   255)
     ${DIALOG} --backtitle $"CDcontrol v${CDC_VERSION}" \
         --msgbox $"Canceled by user." 7 30
     exit 1
     ;;
 esac
 # Cut out "" from selection
 L_MAT_NAME=`echo ${L_MAT_NAME}|sed -e s/"\""//g`


 ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" --clear --title $"Confirmation" \
         --yesno $"Do you want to delete the CD image '${L_MAT_NAME}'" 0 0

case $? in
  0)
   if ls ${TMP_DIR}|grep 'recorder'|grep 'busy' >/dev/null;then
    ${DIALOG} --clear --title $"One recording is running" \
    --yesno $"CDcontrol has detected at least one recording process running, do you want that \n\
the CDcontrol schedule this delete to happen after all writting be\n\
finished?" 0 0
    case $? in
      0)
       cdcontrol_apaga_img ${IMG_DIR} ${L_MAT_NAME} ${TMP_DIR} &
       exit 0
       ;;
      1)
       clear
       ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" --sleep 5 \
       --infobox $"'${L_MAT_NAME}' was not deleted, canceled by user..." 7 70
       clear
       exit 1
       ;;
      255)
       clear
       ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" --sleep 5 \
         --infobox $"'${L_MAT_NAME}' was not deleted, canceled by user..." 7 70
       clear
       exit 1
       ;;
     esac
   fi
   cdcontrol_apaga_img ${IMG_DIR} ${L_MAT_NAME} ${TMP_DIR}
    ;;
  1)
   clear
   ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" --sleep 5 \
     --infobox $"'${L_MAT_NAME}' was not deleted, canceled by user..." 7 70
   clear
   exit 1
   ;;
  255)
   clear
   ${DIALOG}  --backtitle $"CDcontrol v${CDC_VERSION}" --sleep 5 \
     --infobox $"'${L_MAT_NAME}' was not deleted, canceled by user..." 7 70
   clear
   exit 1
   ;;
esac

exit 0