0% found this document useful (0 votes)
7 views12 pages

KJS JOURNAL PAPER 2, Development of Rename Directory Command in MS-DOS

The document discusses the limitations of renaming directories in MS-DOS and presents a new method developed in Turbo Pascal 5.0 to rename directories without following traditional procedures. It outlines the structure of MS-DOS disks, including the boot area, file allocation table, and directory area. The author highlights the challenges faced when trying to rename directories and proposes a solution to enhance the MS-DOS operating system functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

KJS JOURNAL PAPER 2, Development of Rename Directory Command in MS-DOS

The document discusses the limitations of renaming directories in MS-DOS and presents a new method developed in Turbo Pascal 5.0 to rename directories without following traditional procedures. It outlines the structure of MS-DOS disks, including the boot area, file allocation table, and directory area. The author highlights the challenges faced when trying to rename directories and proposes a solution to enhance the MS-DOS operating system functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

4 , 19 9 4 ' p p ' 33-44

A d v a n c e s i n l ' l o d e I l - r n g & A n a I y s i s , A , A l ' l S EP r e s s , V o . L' 2 2 , N "


Received Feb. lB, 1994

CI]MM AND
DIRECTORY *
IN M S_DOS
OF RENAME
D E V E L OP MENT
K. J. Sateo
Assistaut Profes6or
DePt. of ConPuter Sc' aDd 8D99"
B. il. college of Eogg.r
- Iavatnal
PUSAD - {45 215' Dist'
Mabarasbtra (INDIA)

Abstract

}|S-DOS bae tbe followiog coqmaods for tbE


The oP€rrtilg Eyater
a n d R I I D I R ( R D ) i ' e ' t h e r e i g tlo
directorlcr- CEDIR(CD), lll'KDIR(ltD),
RENDIR) sbicb caerld reraae a directory.
conoand io us-Dos-triie
RENAIIE(REX) in Ms-Dos' btl coonasd
fhere is I conoand called . fbi"
rensEeatbefirstfilassasecondfile.Eveuthougbthedirectory
area oo tbe disk ag a file naoe'
Dsoe is stored io tbe directory
r e l a n e d b y t b e R E N r u I E c o o n a n d ' If $re
tbis directory nane c a n q o t b e
b y t b e R E N A I ' { E c o a l ' l a n d w e g € t atr
try to reDaioe a directory Daoe
pati or fili naoe"' I an glving' lrerewl'tb' a
error Ees6age "IDvalid
a c o o o a o d t o r e u e n ' r a d i r e c t o r y aDd cao bE
c a d a c t a 6
-par o g r a l a w b i c h
g-oa enbanceoeot to tbe Ms-DoS operating systen'

l.O Existing Procedure to RenaEe I qi:elErr 3

pilectlyreDaaiugadirectorygaa6lauotPoEsiblsitr}ts-Dos.TboMs-Dos
ploced.u,re to renane a directory whicb ie very
ra.ndal gives tbe followiog t h e D a nual
f o r r e n a c i r ' g & d i ' r e c t ' o r y a E P e r
uuch error prona. Tb€ procedure
is as under...

1> Create a new directory '


2t-;;;; iut rtt.o froo tle old dj'toctory to tbe uevi diroctory''
3l o"iete t b e c o a t e nts of tbe oltl dli;ectory'
IJ Reooua tbe old directorY.

prubleoe rrith tbis procedure are as under" '


the
I
area on the di'ak becooes ful'l then we can[ot
1> If tbe root dl'rectory
create I n a w d i r e c t o r y o n t b a d i s k '
files froo tbe old directory to tbe DeH
2> Horoally for copyiog tb:
r'r to tbe new directory' Tbis process
directory lfe uaa ttnE coonana coPy
wbich ray create a probleo of the data area ou tba
duplicat-s tbe files
disk becooing full.

stop copying and, searcb tbe unwanted files wbicb


Ir tbi6 case we have to
could be deleted.

is copy r ' r does oot coPy tbe hidden and systen


8ut tbe biggest probleo
flres but tbeir attributes becone archlve
files.rt csn
" " p i - i i " - i u i a ""iy
in the Dew d i r e c t o r Y
a subdirlctory witbin a subdirectory then the copy coooand
-3;>; p Ii f; ; t b e r 6 i s
only the subdirectory nan€ and not tbe files in it'
directory ws noroally uss del
-4 > F o r d- re. rl e h ti ci nbg - c r et ahtee s c o n t e n t s o f t b e o l d
;:; a probleo lf tbere are bidden/systeu/read only files
r'r canDot delete tbese files'
in tbe directory becauie DEL
5 > R M D I Rd o e s D o t w o r k u n l e s s i t is nade enpty'
I
a.progra[ which will
I
l
fn order to solve tbe above problens I bave developed is
renarDe a directorf witbout- f o l l o w i n g t h e a b o v e P r o c e d u r e . T b e P r o g r a n
I 'l
rrrit-ter ia turbo Pascal 5.0 under Ms-DoS '01'

PreseotediDaDlDteroationalConfereoce,AUSE'sDs'93'Bangalore'INDIA'
34
2.O Introduction:

tbe details of rsoamiug a directory lt il worthwhila to


Before w6 go ioto
ir to bow tba directorier aro atored oa thc dl-lk, rathsr for tblt
understand
wbat ls the loglcal gtructure of a disk. Eero we congLder 360 KB DSDD
oatter
floppy diskettee.

is divided into four saparate areag. Tbese rr€...


Ev€ry l.{s-DoS diskette

1> Boot area/Boot aector,


2> Flle Allocatioa fabl€(FAT),
3J Directory area/Root,
{> Data area/Data sPace.

Let us now look briefly into tbese four areas'

2.L lbe Boot Area !

tbe boot sector is tbe oth sector on the disk and con-
rb6 Boot area l.e.
talns two tbings,naoely,tbe boot paraneters and tbe disk bootstrap PrograE.

purpoEo of tbe disk bootstraP progran is to load us-DoS files reeidiog


tbo
iuto tbe oeoory. Tba boot paraoeterl ara used by o.s. ant
olr t-be iist<ette
ia perforned oD the dlsk. Tbc boot paraoetcrr
tioe a read or wrLte operation
are. . .

Length Disk Value


Deecri.pt ioo
. Bytec

Jump J,aetruction 3 Bytes EB 3c 90 EB 3C 90


Systeo ID 8 Bytos {D 53 {'0 {F 53 3{ 2E 30 l,rsDos{.0
2 Bytes 00 02 5L2
No.of bytes Per sector
No.of sectors Per cluster I Byte 02 2
No.of sectors in reserved area 2 Byts 0l 00 I
No.of copie8 of FAT 1 Byte 02 I

root directorY entries 2 Bytes 70 00 112


Ho.of
Total no. of sectors 2 Bytes D0 02 720
lledia descriPtor 1 Byte FD FD
2 Bytes 02 O0 2
No.of aectort Per FAT
2 Bytes 09 00 9
No.of tectors Per track
No.of sides 2 Bytes 02 00 2
No.of bidden aectora 2 Bytes 00 00 o

above paraDetera, aPart froo tbe flrst 1l byter r€8t lt called a3


of the
BIOS paraneter block (BPB).

2.2 File- Allocation Table !


rrea'
tbe FA! occupies { sectors(sectors 1 to {) on tbe disk after tbe boot
tbe di:k'
lbe FAr Eaps the usage of all the disk sPace itl the data sPac6 of
coDtai;s tbe iaf6rnation about tbe space used by €8ch indlvldual file,
It
unused disk space aud the sPsce tbst ir unusable duc to dcfectr in tbc
tba
slnce FAT coDtaior vital inforqation, two coplar of FAT arc rtored On
dirk.
disk, j u s t in ca66 o D e g e t r d e s t r o y e d , t b e o t b e r c a n b c u r e d ' A F AT
the
aotry cau cootaio any of tbe following I

- Unused cluster
- Reserved cluater
- Bad cluster
- Last cluster in the file
- Next cl.uster number ln the file
35
Tberois o o e e n t r y i n t b a F A l f o r e a c h c l u s t e r i o t h e d a t a a r e a . | f t hc leu s t e r '
or defective
value in a FAT €Dtr| aoesn't nark an uoused' reserved and tbe
tbeo tbe cluster .iit""pooding to tbe FAr entry is a part of a file'
value io the FAT.ilry i""fd indicate tbe next cluster in tb€ file.

giveu fl'Ie is napped by a chaiu


Tbi6 roeaus tbst tbe sPaco tbat belougs to a chaiu.
e n t r i e s , o t w h i c b p o i o l r t o t b i next entry in tbe Th"
of F A A nuober in tbe
o , r".ru. i
" r i o t h e c h i t n t g t h s . t a r t l n g cruster
first cruater
a file i s c r e a t e d o r e x t e n d e d ' M s - D o s a l l o c a t es
filer,s directory.otiy.-wu"n
clusterE(discussedl'ater)totbefilebyEearchiDgtbe.FAtforunusedclus-
terEaodaddingtbeotottrocbain.oDeclusteratatirnele a l l o ci ra t edda lt eot e
ad'
file includiog a subdirectory eatry' Vice verss' wbeu a file
} | s - D o s f r e e c t b e c l u s t e r r t h a t h a d b e e o a l l o c a t e d t o t b a f i l e o rFaAgTucbbda ii ur e c f-o r a
ahe
tory entry by clearing tbe correspondiag FAT eotries'
fili entle *ith an entrl FFFF iu tbe FA?'

2,3 The Root DirectorY :

t b 6 r o o t d i r e c t o r y u s u a l l y o c -cau p i e r ? s e c t o r s a f t € r F A r ( g e c t o r s 5 t o l 1 )t .bTe bs ee 3 2 byte


serils of 32 byte eltrle8. Each of
root directory containe of
a subdireltory o " " . o r t h e v o l u o e l a b e l
entries arc €itber ! fil€naDa,
t b a d i e k . I f i t , r a f i l c e u t r y , t b e 3 2 b y t e e n t r y c o n t a i n e . i n f o r r n a t i o n a b aonudt i t ' e dats
startiog locatioo oo ibt disk; it'r size'
file'r size, it'r
i s p r e s e o t i n t b 6 f o l l o w i n g order'
aod tioe of creation. Tbis i n f o r n a t i o n

::::::i::::-----::::------:::::-----::::-:t::-----------------
Fileuaoe I Bytss ASCII 41 49 52 30 30 30 30 31 DIR00001
. DAT
Extension f alter AscII {{ {1 5{
10 16
Attribute I iYt" Bit coded
Unused AII zeros All blaakr
Ressrved for lO Bytes
future use 12:36a
Tioe 2 BYte3 Encoded 98 O{
E3 1A 07-03-93
Date Z iYt.s Encoded
60 Ol 352
Starting clu- 2 Bytes Integer
ster nuobar All blankr
Size { BYteB LoDg INT All zcrog

T h e a t t r i b u t e o f a f i l e c e n b e . . . r e a d o n l y ( 1 ) o r b i d d e n ( 2 ) o r s y s t e o f i l e of
;; directoryl16; oi arcbive(321 or a conbiuatiou
(4) or volune ID(8)
o u f y l U i a i " u r s y s t e o f i l e . A - s ubdirectory can elro
tbese a.g. IO.Sxs is i-reaa hidden -or
l.e. s lubdirectory c a o b e r e a d ouly or
bavo such ! rttribute entry alro
o r ! c o m b i n a t i o n o f t b e s e . F o r a subdirectory
ayrten or lrcbivs
one cluster is allocated.
the file or
Iu tbe attribute byte each bit represeote either tbe type of
sub diractory nanc entry' Tbc
wbetber tbc eotry ie a voluoe label eutry or a
neaning of cacb bit is al thown belor" '

Bit nulbers l.leqDing


7 6 5 { 3 2 1 0

Read onIY
Eidden
Systeo
Volune label
Sub directory
Arcbive bit
Uaused
UDused
36
ahs rtartlng cluster n 'nlrer indicates tbe pl,ace wbere tha flle beginr on the
dlck data space. !e3 v6|'ae label entry the startiug clu-t€r o,,.f,"" rr o.
For tbe directory entry wbicb ir a sub directory aod contalnr rnotber files,
the root dLrectory eatry cootaing a starting cluster no. of another ret of
directory entries which reeide in tbe disk data 6pace e.g. tf DrRl ig r
subdirectory in the root directory whicb coutains DIR2 aa a rubdirectory
along with tbe other filee, and DIR2 cootaios DIR3 ae a rubdirectory aloug
wl'tb tbe otber files, aud DIR3 contains a set of filer tbea tbe root direc-
tory entry will contaia only one entry for DrRl which wl.Il glvc the addrear
of DrRl on tbe disk data space nbere all it,c fileg will be located; in DrRl
tbare rill be on. entry for DrR2 whlcb will glve thc eddrotr of Dlni oo tbe
dirk data rpace; DrR2 will contain ooc entrl for DrR3 wbich lrill givc thc
addrcrr of DrR3 on tha dl-rk data apac6, and on tbl,t eddrcrr all th. filot of
DIR3 will be located.

2.4 Th€ Data Space i

All flles' data and subdirectories are stored iu this area. It occupiee tbe
laet and tbe largest part of each disk.

l'ls-Dos allocates epace to fileg one clustcr et a tine. A clurter ir oothiog


but a grouP of sectors that Ms-DoS allocates to a filo at a tine or r subdi-
rectory €Dtry or a volu.re label.

At a file ir belng created, or ao existing file ig extended, tbe file,r


sllocated EPac€ grows. l{ben nor€ Bpaco is needed, xs-Dos allocater auotber
cluster to tba file.

3.O Proqran,e Logic !

we caD coopile tbe progran. giveo berewitb, ia tha turbo percal 5.0 anviron-
nent aod genarato aD €xecutabl,e filc, call,ed RETDIR.EIE. I:hir prograr cao ba
executed froa the l{s-Dos proupt ia two }rat8. ru tha fir:t rray Ho ca[ giv€
Just the naoe of tbe prograo vi.z. A>R!$DrR<enter>. ro tbc reioud rr!1, irc ceo
b a v c A > R E N D T Ro l d _ d i r e c t o r y new_directory<eDter>. tt RETDIR.ETEexirt: iu
tha root directory and wg are fn sooe otber path tben we can invoke tbe
prograD by \RENDIR<eater>e.g. A3\Kt\K2\K3>\RENDtR<eutcr>.

lf we invoke the Progrsn witbout any paraoeterB or paraDeterr oot cgual to


2 thea the progran disprays the following oessage and asks u! to gi". the
old directory DaEe...

rEIS PROCRAI'{ IS FoR RENAI'IINOA DIRECToRY...EHTER oLD DIREC$RI Xltt{E DR:\pAtE


\ D r R N A I . { E ( M A r . 6c sE A R s ) . . . o R . . \ . . \ . . \ . . r . o R r . ro R . . \ . . \ . . \ . . \ D r n E c t o R y xAr,G
FORT.'

lhe user ie supposed to give the old directory oaoe. tbe progra. theu askc..
E i l r E R N E W D I R E c t o R y N A U E D R : \ P A a E \ D I R N A " L E ( t { A r . G 5c E A R s } o R . . \ . . \ . . \ . . FoRtl
OR ..\..\..\..\DIRECIORI N A U E F O R I . T . D E F A U L TP A T B O r r B E S O U R C ED I R E C T O R YI S
AI,LOWED.USE lEE SAl.lEDRIVE...

Tbe user ir aupposed to give tbe new directory naoe.

rf the paraoeters are given then tbe paraDeter! arc aasigned to tbe old
directory ''ea€ aud the new directory DaEe. Botb tbe dirlctory na'ei !16
first converted iuto tbe capital letters. fha first routina exeluted ir tba
PAls-cEEcK. Tbie routine cbecks whether both the previoue paths(prior to the
glven dlrectoriea) ar€ aane or trot. }le oeed oot give tbe path uaie explicit-
ly in both tbe dirdctory naoes. l{e cao give the latb nare-only ln one of tbc
directory tra'es, tha progra' cau take the other path lraoo fro' tbia. Tbig
tt

routioe rlto cosvcrtr botb tbc dlrectori BaEet ioto tbc 8 + 3 fornat l'c' 8
cbrrlcterr priDrry D!E! rDd 3 cbsractcrr tecondary oane. If we want to
renlo€ the curreot dLrectort then we cau give just . for tbe old directory
DaECO.9.

A:\Kr\K2\K3>\REIIDIR . KK <6ut€r>. Tbit will reuaoe tbe curreot directory to


A:\Kl\x2\Kf,>' l{o cad u68
RX' eod tbc propcr ProdPt vir. "\"\"
"ill'gl"c naEea. But a ProPer care bar to be takeo
coobiDatioa for botb tbe directory
wblLc usiug thlt coablnatioa In the nEn dirsctory DaD€ €.9. w€ c8! ua6

rr\f,I\K2\K3>\REllDtR ..\.. ..\..\..\Kx. rblc nitl renlEa f,l to Kx aod Hlll


glve tbe'proopt A:\r.x\x2\K3>. If tbe proopt ts A:\Kl\K2\K3> and K3 contll.nr
R4 aod we wlnt to renaoe K4 tben we c8n uao

Ar\Kl\K2\K3>\REIIDIR X{ R5. Tbe rensol.og will be doao and se will have tbe
rruc proopt. Tbs drive lett€r cao bd given or it can bE ooitted e.9. 116 catr
u3!. , .
rr\xl\f,2\r3>\RErDrR ttf,l Xx or A'\K1\X2\f,3>\RENDIR \Ki RF c',r
r: \xl\[2\R3>\REHDIR l!Kl ArKK or Ar \xr\R2\K3>\REHDTR \Rl A3Kx or
A:\Rr\x2\R3>\REHDTR \Kl \K2 etc.

l{. crn reolEs .nt otber dlractorl out of tbls patb alro, but r ProP€r Prth
bar to bc Aivcn el leart lo ooc of thc directorl DaEe!. If tbc patba of tha
old direclory neoo lud tbe uew directory naoe don't Eatcb theo tbe' Progran
givea tba D.3r!96. . .

PAIE/DRIVE IS NoT ALLOWED...COMHAND ABORTED...and tbe Prograo


DIFFEREIIT
eodg.

tb! prth na6er ere tba rioc then thc Progr.D rxecutes tho routioe
tf
rdd. the drlvc naoe A! or 8: or C: or Dt or E! to tbe
ADD DRTVE NAl.fE sblcb
o t 1 U a d l r e c t o r y n r E e i f t L ir not sPecified. lfter tblr tba
lrtfi
routirc 1 r e x e c u t c d . T b l r r o u t i n e i r r c q u l r e d b e c a u l c lrc
CEECK CUR DtR
e dlrcctory rbco wr !ra currootly ln tbe raos dlrectory' lf ra
caonoE r.iaae
directory tbeo we bave to 9o to it'r previoul
1rs6t to r3oaDa tbe curient
t
directory in tbe raoe p l t h . T h i r r o u t l n e d o e r t b l s t a g k '

!re €x€-
-l
a a d t h e D I R _ N A J . I E - C E E C Kr o u t i D e s
After tbit tbc l{ILD CEECK routine
cuted for tbe old -i;""l"ty
routiue
naoe aod tha nerl direct6ry
cbcct<r srbetbar tbl wtld Cardr r eod ? are prareot
t b e d
oaoe. Tbe

i r e c t
in tbe
o r y
WILD-CEECK
directory
DaEe. ll€ cad
ii
oaoeB. t t a l s o c b e c k r r b e t b e r b l a o k l s P r e E e D t l n
cenoot bc i
cr€lto r dlrsctory baviog a blaok ln !t'. Drre a.E. DIR 01, but lt
by tbc X3-OOS'! CD or CEDTR coonaod, lo blank lr Dot lllowed io the
rcce3red
iaae. It l n y o f t b c d i r e c t o r y l a 6 s t c o u t l i ! ( i n 8 + 3 ) t b e s e char-
directory
ecterg i.c. I or ? or blaok tbea tbc progra! 91v3. tbc acrrage...

TIILD CARDS ? & r A}ID BLATKS ARE NOT AI.LOWED IN A DIRECIORY NAME.. 'COHI{AI{D
ABORTED... and tbe Prograo ends.

cbeckr thrt non6 of tba directory naae! !r€ null


rb€ DIR_NAXE_CEECX routiD€
flle reserved words viz. CoMl or CoM2 or LPT etc.. If tha
or tbe- xs-6os
directory n!!o€ 1t oull t b a n t b e p r o g r a n g l v e t t h c D e s r s g s " '

prograo cndr' If
DIRECToR! NAYE CANNoT BE NITLL...COMuA.}|DABORTED... aod tbc
tbe directory DaE€ is one of tbe l.ls-Dos reserved file naoee then the Prograo
giver tbe EeEsagG.. .

AUr/ CLoCKs/ CottL/ cott2l col{3,/ coH{/ coN/. LPXLI


DTRECTORY NArqE CANNOT 8E...
L P T 3 I L S r l X t t L / P R N . . . C o l . { 1 . { A } f DA B o R T E D . . . ' a n d tbe prograo ends.
Lpt2/
tbir tbc DIR_CiECK_I routlne is executed wbich checkr sbetber tbe old
lfter
o; not, if it exists tben it ir a directory or not'
directory naae exfsts
38
IhLa routina checks all tbe possible(16) attributea of a directory i.c. read
only or hiddea or aystea or archive directory or a coobinatioa of tbess. If
tbe old directory aaoe ir not a directory or i,t doos not axl,rt theo tbe
progran givcr thc Eeslago...

r I J N A - I ' { E ,D
' oEs Nor Exrsl o R } l o r A D r R E c r o R Y . . . c o M l ' t A } I DA B O R T E D . . . , a g d t t r e p r o -
gran ends.

After thig tbe DIR cEEcK 2 routine is executed wbicb cbeckr whather the Derr
directory nane ie f direEtory itseJ.f. rf so then the prograr givee the nea-
sage.. .

otrrHAME' rs A DrREcroRY rrsELF,..CoMMAND ABoRTED...' and the progran enda.

After thir the PrograE axecutes the routiae sA.l-{EHAJ.iEsbl,ch chGck! whatber
iirs rliri riirecto-t nans ard tbe seer di.=ectory laoE era diffarent or uot. If
they are oot dlfferent then the prograE gl.yar tbe ncreage...

RINDIR CANNOT RENA.I.{E


SAI'{EDIRECTORY...COHT'{A}ID
ABORTED... end the progralr
ends.

After tbis tbe Progra& executes tbe routiDs FILE cEEcK. Thir routlae cbecks
wbetber tbe new directory nane existr on tba disE ar a fila. If Lt cxirtr ar
a file naoe olr tbe disk, io the particular patb, tben the progran gLver thc
following EesEage aod asks tbe following questioo...

. . .AS A FILE Ol{ IEE DISK'


,,ouTtilA.ME,, ...TO CREATE It AS
"oLIfNAl'{E,' A DIREqTORy ? (y11,

rf tbe u6er responds witb Y/y tber tba progral daletcr thc fil.s frol tbe
disk 5o that a directory could be reaaucd as that naoe, othcrsiro tbs pro-
gral givee the nes:age...

' . . . C O M I ' { A N DA B O R T E D . . . ' a n d t h e p r o g r a n e n d s .

rf the old directory Da&e ig tbe curreut diractory naoe thea tbe
cEEcK_cuR_DrR routine 6 e t s t h e v a l u e o f t b e v a r i a b l e o D _ E Q _ c Da s T R U E . r f
OD-EQ-CD is FAISE tbea tbe routine HIIBIN PATE is erecuted. tbir routl.ae
chCcki wbetber tba old directory nane is iicluded io tbe curreDt directory
Dane. If it is so then tbis routine sets tbe value of tbe variabLe INpATg to
b€ TRUE. fhie is required to cbange the pronpt correctly.

After thie the Progran converts the old directory aanc eod tbe nap directory
nsDe into tbe ASCIIZ string, a n d l n v o k e g t b e M S - D O Sf u n c t i o a requert 568
wbicb does tbe reuaning. ff tbe operation is successful then tbe progr8ll
gives tbe Desaage.. .

' D I R E C I O R Y . . . ' , I N I { A M E , , . . . R E N A f i E DA S D I R E C T O R Y . . . , , O U : I N A N E
and th6 prograq
ends after giviag a correct prorupt. If the operation ir not ruccergful tben
tbe prograo gives tbe uessaga...

' D r R E c r o R Y N o r R E I I A I . { E D . . . c E E cAKc c E s s
RrcETs...'and the progran ends.

{.O Acknowledqements r

Tbe autbor is bighly tbankful to prof. B. M. Tbaker€, priocipal, B. l{.


college of Engineering, Pusad and Frof. D. J. Das, B.o.D., coEput€r sci€Dc8
aod Engiueering, B. N. college of Engineeriug, pusad for naking the facili-
tier available for tbis work. The author is higbly iodebted to Hr. R. s.
varoa and llr. s. iI. Doiphode aod prof. R. B. patil of B. N. colrege of
Engg.,Pusad for testing the work and for useful suggestionc.
'lo

5.O Prosran for tbc connand t

RE}{DIR'
PROGRBI,T
{PROCRAI{ FOR REI{A.MS DTRECTORT BY PROF.
K . a t . s A T A o , B , N . C O L L E G EO F E N G C . ' )
- 445 215, D I s f . : I A V A T I { A L ' I.IAEARASETRA ( Ir.IDIA) }
{PUSAD
USES DOS;
CONST
D=DIRECTORY }
{ R=READ OT{LT, B=B I DDEN , S=STSTEII , A=ARCBIVE , = zLi
= 23;REJ$ = sl;NtrD = l9;RSAD = 53'RSD
RISAD = 5siRf,SD
=tl9;RD =l?iBsAD =5{;EsD =22,EAD =5OitrD = lgi
RAD
= 5 2 i s D = 2 0 ; A D = 1 1 8 ; D =LGi
sAD
CARRI_EIAO = li
F I L E S E ! r A R R A I t l . . 1 3 l o f S a R I N c [ 6 ] = ( ' A U I ' r ' C o N ' , ' L S l " ' l f u',LPT3
l , " ' P R ] f',"
' coM1 ', COtt2 ; , ', COM3 ', CONo 'LPTl ', . 'r'PTz CLOCKS ', ) i
VAR " " " " "
Fl!F2 : FILE;
AITR : WORD,
CE ! CEAR;
REG S REGISTERS;
I,DR_No ! IITEGER,
Pl,P2 ! PATESTR,
D1,D2 ! DlRSTRi
N1,N2 t NAMESTR, .!
EL,Ez : ElTsIRi
S,sl,S2 t STRING;
Kl ! STRING[2] i
rOUilD'OD-EQ-CD,IIIPATB ! BOOLEAI{;
INNAI.|E, Ot1ttlnl,tE, tNA.l't3,ONAUE s STRII|C [72 | ;
PROCEDURE DRI''E-XO(DIRNAI.IE : SIRING) i
BECIN
s l ! = , , i 3 2 . a " i
s1 8= coPY(DIRNAIIE, 1, l)i
52 := coPI(DIRtlA'l{E, 2, lri
,:, T8Eil
IF 52 =
BEGIH
If ( ( S 1= ' 8 ' ) OR(Sl = 'A') T H E N D R _ H OI = I;
IF ((Sf = 'b') OR(Sl = 'B') IEEN DR-NO := 2i
((Sf ='c'l OR(31 = 'c') rEEil DR NO t= 3i
If
((Sl ='d') oR (Sl = 'D') TEEN DR-No := {i
IF
((sl = 'e') OR (S1 = 'E') IEEN DR_No != 5;
Ir
E}TD
ELSE
DR lto := 0;
E}ID;
PROCEDT'REPATE-CEECK;
SAME OR NOT)
{ROUTINE IO CEECK WEETEERTEE PA1E NAT'{ESARE
L A B E L1 , 2 , 3 r 4 , 5 , 6 i
VAR
L,N : I}f,IEGER;
BECIN
DRM_NO(INNAilE);
L != LENCIB(INNAI.IE),
oETDTR(DR_XO,S) ;
'.'))
IF ((L = l) AND (MNAltE[1] = TEEN
BEGIN
INNAI,TE T = S;
GoTo 5i
END;
I := li Kl := "; H := o;
'.'
IF INNAf.TE[ll = IBEH GofO I
ELSE GoTo 5i
40
l:Kl := INNAITEtIt + INNAI'{ElI+11t
IF K1 ='..' IEEN tl := N + 1 ELSE COIO 2;
1 3= t + 3i
coro 1;
2 : I T N > O T S E N
BEGIN
P1 := Si
F O R I r = l t O N D O
BECIN
Dl := ";
FSPLTT(P1, D1, N1, E1)i
Pl := Dli
D E L E T E( P I , L E N G I E ( P 1 ) ' I ) ;
END;
DELETE ( INNAME, 1,t|r2+N-1 ) ;
INNAI.{E != Dl + INNAUE;
DELETE ( rl[NAl'lE, LENCTB (Dl ), I ) ;
END;
5: DRIVE-No (OUINAME ) ,
L := LENGTE(OUNAT'{E);
o E T D T R ( D R _ N O ,S ) ;
= IBE}I
IF ((L = T) AND (ourNAr'{Et1l
"',))
BEGIN
oUrNAME := Si
co10 6;
E}ID;
r i= l; Kl != "i N :g oi
= '.' IEEN CioTO 3 '
tF Orxr!|AltD[l]
ELSE GOTO 6i
3:R1 := oUfNAlrEtIl + otJ1INAuE[I+11;
I F K l = ' . . ' T E E NP 3 ; | f * I '
ELSE GoTo {i
I := I + 3i
ooTo 3;
IIIIFN>OIEEN
BECIN
Pl := S;
F O R I : = l I o N D o
BECIN
Dl := "i
F S P L T T ( P 1 ,D 1 , N 1 , E l ) i
Pl t= Dl;
D E L E T E( P 1 ' L E N G I E( P I ) , 1 ) ;
END;
DELETE(OIITNAI'IE, 1,Nr2+H-l ) ;
O(IrNAITE := Dl + OUTNAI-{E,
DELETE(Ot :TNANE.LENGIE (Dl ), 1 ) i
ENDi +
- '\' IEEN IIINA]IE := s[1] + sl?!
IIIrr|E'
6sIF INNA$g[1]
't' rseN OuINAME := s[1] + S[2] + ottlrlN{B;
IF oulNAr,mtll =
Pl := II{NIIME,
F S P L I T ( P 1 ,D 1 , N 1 , E 1 ) i
II{NAHE l= Dl } Nl + El;
P2 := OUTNAHE,
FSPLTT(P2, D2, N2, E2li
OUTNA.UEr= D2 + N2 + Ezi
IF (Dt = ") TBEN
BEGIN
Dl != D2;
INNAIIE := Dl { INNAUE;
END;
41
IF (D2 = ") TBEN
BEGIN
D2 r= Dli
OtrtNAJ'{E := Dl + OIIrHA$E;
END;
IF Dl <> D2 TAEN
BEGIN ., ) i
AI'LOWED.. 'COT'fiAND AAORIED..
WRITELN('DTFFERENT PATB/DRIVE IS NOA
CEDIR(s) iEAI,Ti
END;
ET|D;
PROCEDT'RE ADD-DR I VE-NAT'{E i
BEGIN
32 r= "i s2 != coPY(Dl, 2, Lli
' ! ' TEEN
IF s2 <>
BEGIII
DRrVE_NO( INNAT'{E) ;
c E l D l R ( D R _ X O ,S ) ;
j,.-
S1 := 5 1 r = C O P Y ( S ;1 ' 2 ) i
INNAJ'|E != sl + INNN{E;
END'
s2 r= "i
s 2 ! = c o P Y( D 2 , 2 . l l i
tF 52 <> ':' TBEN l:-!

BECIN
DRIvE-No(OIIINAI.{E) i
G E T D I R( D R - X O ,s 2 ) i
Sl := r,.- Sl t= COPY(S21 Lt zri
O(JITNAMEl= S1 + OIXTHA$E;
ENDi
ENDi
PROCEDT'RECEECK,-CT'R_D I R;
DrR rs TEE CI'RRENT DrR)
(ROUrrrE ro CBECK wEernin tEE SOttRcE
BEGIN
OD_E9-CD s= FAI,SE,
DRIVE-NO( IHNAUE) ;
S : = " i
cE?DrR(DR_NO,S) i
pl := ,'; Dl := "; Nl .= "i EL r= "i
IFS=INllA-l-{ETEEH
(
BEGIN !
I

OD-EQ-CD := TRUE;
Pl := INNAltlEi
,lI
FSPLTT(Pl, D1, l|l' El]i
D E L E T E( D I , L E N C I E ( D 1 ) , 1 ) ;
cEDrR(D1);
END;
END;
PRoLEDUREVIrLD-CSECK(DTRNAUE: STRING-)i
r & ? AlrDBr'Al{xs}
liourrnn ro cBEcKwrLD cAxDs
BECIN
FOR I!= I ro LEXCIB(DIRNAilE) Do
BEGIN
=' r' ) oR ( DIRNA]|E I I | = " ) ) TEEH
t F ( ( D I R I I A I - { EI I | = ' a ' ) o R ( D I R N A I i E I I |
B E GI H IN A')i
}IRITE('I{ILD C}NDS ? I i AND BIINKS AXE NOT ALLOWED
N A $ E . . . C O } T U A N D A B O R T E D . . ., } i
HRITA('DIRECTORY
HRITELN; CEDIR ( S ) ; EALA,
E}TD;
END;
E}TD;
42
PROCEDI,R.E DIR-NA'ME-CEECK(DIRNAME : STRINC) ;

lnourrre ron ilrvnr.iD DrREcroRY NAUEs)


BEGIN
FOITND := FALSEi
If (DIRNAI'{E = "; IEEN
BEGIH
'DIRECTORY XAI{E CANNOT BE NT'LL.. 'COMHAITD ABORTED" ., ) i
WRIIEI,N(
cEDIR(s) i
EAIT;
ENDi
FoR I := I To 13 Do
BEGIN
IF DIRI|AME = FILESETIII TEEH FoUND != TRUEi
Er|I)i
IF FOUND TEEN
BECIH
WRITE('DIRECTORI NN,TE CANNOT BE' ..' );
T2 wr3 | Lsr l' I i
wRrrE (, AUr/ clo;ig I cotrrI coy'2I cout I coiq I coN/LPr I /LP |
ABoRTED" )i wRrrELrt cEDrR(s) i
llRrrEl'xur,7rnx. . .boro'rerro
EALTi
"
EITD;
E}TD;
PROCEDURE DIR-CEECK_I i
tRourrNEro CEECK rEe souncs xA}E EIrsrs oR NOT)
wanrnnRrr rs A DrREcroRY oR Nor)
iexo
BECIH
A s s I G N ( F 1 , I N N A M E ) ; G E T F A T T R ( F 1 , A T T R )i (AIaR<>RSD) nxD
(ertns>READ) AND
rF ( (AtaR<>REsAD) AND (AtTR<>RESD) eri (A!TR<>RD) ll{D
IND (AI!R<>RAD) INL
(ASIR<>RSAD) Ar|D inrtR"gso) (ArrR<>ED) ANI)
AXD iATTR<>EAD) AlrD
(ATAR<>ESAD) AND lnrrn<trso;
AHD (ATTR<>AD)- AND (AlrR<>D))
(ATTR<>SAD) AND (AtrR<>sD)
TBEN
BECIN ',)i
WRITE(INNAT-{E,, DOES NOl ErIsT OR HOr
A DTRECTORY
'
W R I I E L N ( ' , . . " c o M M A N n A B o R T E D.. . ) ; C B D I R ( s )t
BAI,T;
END;
E}ID;
PROCEDURE DIR-CBECK-2 i
DESTTNATTON NAME EXTSTS}
{ROUTTNE TO CEECK Wfrernen
BECIII
ASSIGH(F2,OullNAltE) i GETFATTR(F2' ATaR) ;
OR (AT:rR=R'EAD) oR (AIAR=RBD) OR
(ATTR=RESAD) ilR 6errn=RUSD)
rF (-inrtn=nsno)
oR
oR (ArrR=RsD) oR (ATIR=RAD) oR (AITR=RD)
oR
(ArTR=ESAD) oR aAATR=ESD)oR (AITR=EAD) OR
(AraR=ED)
oR (ATTR-SD) oR (ArTR=AD) oR (ATTR=D)
(ATTR=SAD)
TEEN
BEGIX ., ) i
IS A DTRECAORY rTsELF. . .couMAND AAORIED"
WRIAELN(OUTNAUE,'
csDIR(s);EALTi
El{D i
EHD;
PROCEDURE SAHE-NAfiEi
DTRECTORY NA}{ES}
{ROUTTNE TO CEECK SAI'{E
BEGIN
IF IlrNAr.{E = OIJIINAHE IEEN
BEGII{
ABoRTED...,);
WRITEL}|(,RENDIR cA.t{NoT RENAI.{E SAME DIRECToRI ...coMl.tAND
CEDIR(S);EAI.T;
END;
END;
43
PRoCEDUREFILE-CEECKi ,--
FrLE Errsrs)
lnourr"e ro caEcx wxirssn DEsrrNAtroN
BEGIH
{9r-}
REsEl(F2)i
{9r+}
IFIORESI,LT=OTEEil
BEOIN
wRrlErJ{(',FOUND. . . otIfNAl.{E,',...AS A FILE ON IEE DISK',)i
cLosE(F2)t " '\i
olxfNAl',tE'
'...To C R E A T EI r A s A D I R E C T o R I? l Y l y )
ITRITE (', ERASE. . .
READLN(CE) i "
'Y' TEEx
iF uPcAsE(cE) =
ERASE ( F2 )
ELSE
BECIN , l ?
^^r^tirh lqnDTFll .
HKrJ'ErJl[ .. 'vvrF..DlY

CEDIR(s) tEAL!;
ElrD i
E}TDi
END;
PROCEDURE },ITEI}IPAXEi - oF cuR DrR)
rEE SOLRCE DrR rs A sl'BsEl
tRouTrHE TO CEECK wsirsen
BECIH ,,
I } T P A T ET = F A I S E ; S : = i
DRIVE_NO( rHNAl.{E);
GETDIR(DR-NO, S) i
i^rrrFr \ .
s1 := i,'-s1 := COPY(SrI' LENOTE(INNAUE))'
IF 51 = II{NAIIE fEEl| ItrP418 != rRUEi
END;
BEGIH
=-iirpers {MIIX RoUArrE} := FAISE,
t= FALSE; 6o-rQ-co l= FAI.SE; FotrND
IF PARil.ICOTJNT <> 2 TEEN
BECI}I
A DIRECIORY" ., ) i'
WRITE( ',IEIS PROGRAI{ts FoR RENMTNG cEARs) ' ' )'
wRIrE( 'ENTER oLD DIRECToRI rAHE DR: \PATE\DINltT!111-:65
o R ' ' \ ' ' \ ' ' \ D r R E c r o R v N A I ' | EF o R M )' ; "
r{RrtE('oR . . \. . \.:i.:-;oRM \''
W"RTTELNi
READLN(INNAME) i cEARs)' ) t
l{RtlE(' ENTER NEvf DIREctoRY NAI{ErDR3\PAr8\DIRN1T1I1t:-!5
lrRrre(' oR . . \. . \.;i:l-;oii on :',1::i'' \''\DrREcroRr NAUEFoRil") i
piru or rEE souRcEDtREcloRY rs Ar'LowED')');
wRrrE('( DEFAuLr
DRIVE'"',);
w R r T E ( 'u, s E r s E S A M E
WRITEt}{;
READLN ( OUTNA}TE ) ;
END
ELSE
BEGIN
II{NAME := PARAilSTR(1) i
OUTNAXE := PARAr'tSrR(2) i
ENDi
LENGTE(II|NN{E) Do Ir{NAI{E[I! := UPCASE(INNAMEIII)t
ion't ,= l lo
l= UPCASE(OurNnHBII I ) ;
ion t ,= tr To LENGTE(ouNAI'{E)Do oungA}lElll
PATB CBECR,
eoo-6nrve-xexe;
CAECK-CI'R-DIRi
LILD CEECK(INNAUE);
t
orn frnr'rrcEEcK(r$ilRlIE)
wrLE cueEr(omxAuE);
orn frero-caEcr (otEHAr'{E
)i
DIR_cEEcK-1 i
44
DIR_CEEcK_2
i
SAilE_NA}IEi
FILE_CBECKi
fF oD_EQ_CD = FAISE TEEN IIITEIHPATE;
INAME := INNAIIE,
ONAI'{E : = OtIfNA}tE;
INNAI.IE != INNAME + CSR(O),
OUTNAUE != oUTNAME + CER(0),
WIIE'REG DO
BEGIN
I
DS := SEC(INNAI'IEI1] ) ; . 1
DI r= oFs(I}[NAI.|E[1] ) ; l *
A! != (Ss6)t I
Es 8= sEO(O[trNAr.tE[1] ) t
DI : = OFs(orxrNAr'[8[
1l ) i
H S D O S( R E o ) i
-1
IF ( (TLAGS AIID CARRY_FLAO) ) lEEx
BEGIN
} | R r t E L N ( ' , D T R E C T O R Y N O T R A N A J . I E D . . . C B E C KA C C E S S R I O E T S . . . ' , )i
cnDIR(s);EALTi
END
SLSE
BEGIH
wnrrELN('"tTiTili;"
^;tllffiio*". ".',ourNAltE)i
IF OD_EQ_CD 188!{ CEDrR(OUTNAME);
IF INPAIE IEEN
BEGIN
G E T D ' R ( D R - , , N O ' S ); D E L E T E ( S , l , L E N G T E ( I H A } I E ) ) ,
s !e oNAt'tE + si CEDIR(S)t
E$n;
ErID; .,
ENDi
EI{D.

6.0 Referenceg i I
1> furbo Pascal 5.0 User'3 Guid€. (
ff Turbo Pascal 5.0 Ref€r€nce Guide.
F us-ooE uaer'a Guido and User'r R€fcrencs.
if Prrgirarrer't Refera:oc€ llaoual for faH.iParsonal Cooputer
tsy titevea Arobrr,ret & led Forgaron"
5> Ibe US-Dos Elandbook
By Richarcl Allan Ki,ng.
6> tEr us c
B!' Yarhwaut Kanetkflr.

\
I

You might also like