     1                                  ;	SCCSID = @(#)rename.asm 1.1 85/04/10
     2                                  ;TITLE	DOS_RENAME - Internal RENAME call for MS-DOS
     3                                  ;NAME	DOS_RENAME
     4                                  ; Low level routine for renaming files
     5                                  ;
     6                                  ;   DOS_RENAME
     7                                  ;
     8                                  ;   Modification history:
     9                                  ;
    10                                  ;	Created: ARR 30 March 1983
    11                                  ;
    12                                  
    13                                  ;
    14                                  ; get the appropriate segment definitions
    15                                  ;
    16                                  [list -]
    16          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    18                                  
    19                                  [list +]
    20                                  section DOSCODECODE
    21                                  [list -]
    21          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    21          ******************       warning: out: BPB.INC... [-w+user]
    21          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    21          ******************       warning: out: DEVSYM.INC... [-w+user]
    28                                  
    29                                  %iassign Installed TRUE
    30                                  
    31                                  	i_need	RENAMEDMA,BYTE
    32                                  	i_need	AUXSTACK,BYTE
    33                                  	i_need	DESTSTART,WORD
    34                                  	i_need	DIRSTART,WORD
    35                                  	i_need	CURBUF,DWORD
    36                                  	I_need	NAME1,BYTE
    37                                  	i_need	NAME2,BYTE
    38                                  	i_need	WFP_START,WORD
    39                                  	i_need	REN_WFP,WORD
    40                                  	i_need	CURR_DIR_END,WORD
    41                                  	i_need	DMAADD,DWORD
    42                                  	i_need	THISCDS,DWORD
    43                                  	i_need	THISDPB,DWORD
    44                                  	i_need	THISSFT,DWORD
    45                                  	i_need	CREATING,BYTE
    46                                  	i_need	THISDRV,BYTE
    47                                  	i_need	ATTRIB,BYTE
    48                                  	i_need	FOUND_DEV,BYTE
    49                                  	i_need	FAILERR,BYTE
    50                                  	i_need	EXTERR_LOCUS,BYTE
    51                                  	i_need	SAVE_BX,WORD
    52                                  
    53                                   assume nocheck, ss:DOSGROUP
    54                                  
    55                                  ; Inputs:
    56                                  ;	[WFP_START] Points to SOURCE WFP string ("d:/" must be first 3
    57                                  ;		chars, NUL terminated)
    58                                  ;	[CURR_DIR_END] Points to end of Current dir part of string [SOURCE]
    59                                  ;		( = -1 if current dir not involved, else
    60                                  ;		 Points to first char after last "/" of current dir part)
    61                                  ;	[REN_WFP] Points to DEST WFP string ("d:/" must be first 3
    62                                  ;		chars, NUL terminated)
    63                                  ;	[THISCDS] Points to CDS being used
    64                                  ;		(Low word = -1 if NUL CDS (Net direct request))
    65                                  ;	[SATTRIB] Is attribute of search, determines what files can be found
    66                                  ; Function:
    67                                  ;	Rename the specified file(s)
    68                                  ;	NOTE: This routine uses most of AUXSTACK as a temp buffer.
    69                                  ; Outputs:
    70                                  ;	CARRY CLEAR
    71                                  ;	    OK
    72                                  ;	CARRY SET
    73                                  ;	    AX is error code
    74                                  ;		error_file_not_found
    75                                  ;			No match for source, or dest path invalid
    76                                  ;		error_not_same_device
    77                                  ;			Source and dest are on different devices
    78                                  ;		error_access_denied
    79                                  ;			Directory specified (not simple rename),
    80                                  ;			Device name given, Destination exists.
    81                                  ;			NOTE: In third case some renames may have
    82                                  ;			 been done if metas.
    83                                  ;		error_path_not_found
    84                                  ;			Bad path (not in curr dir part if present)
    85                                  ;			SOURCE ONLY
    86                                  ;		error_bad_curr_dir
    87                                  ;			Bad path in current directory part of path
    88                                  ;			SOURCE ONLY
    89                                  ;		error_sharing_violation
    90                                  ;			Deny both access required, generates an INT 24.
    91                                  ; DS preserved, others destroyed
    92                                  
    93                                  	procedure   DOS_RENAME,NEAR
    93          ******************       warning: proc DOS_RENAME... [-w+user]
    94                                  	DOSAssume   CS,<DS>,"DOS_Rename"
    95                                  	ASSUME	ES:NOTHING
    96                                  
    97 00000000 E8(0000)                	Invoke	TestNet
    98 00000003 7306                    	JNC	LOCAL_RENAME
    99                                  ;	invoke	OWN_SHARE2		       ;IFS.  IFS owns share ?		;AN000;
   100                                  ;	JZ	ifsshare		       ;IFS.  yes			;AN000;
   101                                  ;	PUSH	WORD PTR [DMAADD+2]	       ;IFS.  save DMAADD		;AN000;
   102                                  ;	PUSH	WORD PTR [DMAADD]	       ;IFS.				;AN000;
   103                                  ;
   104                                  ;	invoke	IFS_SEARCH_FIRST	       ;IFS.  search source name	;AN000;
   105                                  ;	JC	nofiles 		       ;IFS.  not found 		;AN000;
   106                                  rename_next_file:
   107                                  ;	invoke	IFS_REN_DEL_CHECK	       ;IFS.  do share check		;AN000;
   108                                  ;	JNC	share_okok		       ;IFS.  share ok			;AN000;
   109                                  ;	MOV	AX,error_sharing_violation     ;IFS.  share error		;AN000;
   110                                  ;	JMP	SHORT nofiles		       ;IFS.				;AN000;
   111                                  share_okok:
   112                                  ;	PUSH	CS			       ;IFS.				;AN000;
   113                                  ;	POP	ES			       ;IFS.				;AN000;
   114                                  ;	MOV	SI,[REN_WFP]		       ;IFS. ds:si -> destination name	;AN000;
   115                                  ;	MOV	BX,SI			       ;IFS.				;AN000;
   116                                  fndnxt: 				       ;IFS.				;AN000;
   117                                  ;	LODSB				       ;IFS.				;AN000;
   118                                  ;	CMP	AL,0			       ;IFS.				;AN000;
   119                                  ;	JNZ	fndnxt			       ;IFS.				;AN000;
   120                                  ;	MOV	DI,SI			       ;IFS. es:di -> end of destinatio ;AN000;
   121                                  ;	ADD	BX,2			       ;IFS.				;AN000;
   122                                  ;	invoke	SkipBack		       ;IFS.				;AN000;
   123                                  ;	INC	DI			       ;IFS. es:di -> last component of ;AN000;
   124                                  ;	MOV	SI,DI			       ;IFS.	      dstination	;AN000;
   125                                  ;	MOV	BX,[SAVE_BX]		       ;IFS. ds:bx -> last component of ;AN000;
   126                                  ;	CALL	NEW_RENAME		       ;IFS.	      source		;AN000;
   127                                  ;	MOV	AX,(multNET SHL 8) OR 17       ;IFS.  replace ? chars with	;AN000;
   128                                  ;	INT	2FH			       ;IFS.  source and issue RENAME	;AN000;
   129                                  ;	JC	nofiles 		       ;IFS.  error			;AN000;
   130                                  ;	invoke	DOS_SEARCH_NEXT 	       ;IFS.  serch next source 	;AN000;
   131                                  ;	JNC	rename_next_file	       ;IFS.  rename next		;AN000;
   132                                  ;	CLC				       ;IFS.  no more files		;AN000;
   133                                  nofiles:
   134                                  ;	POP	WORD PTR [DMAADD]	       ;IFS. restore DMAADD		;AN000;
   135                                  ;	POP	WORD PTR [DMAADD+2]	       ;IFS.				;AN000;
   136                                  ;	ret				       ;IFS. return			;AN000;
   137                                  ifsshare:
   138                                  
   139                                  %IFN Installed
   140                                  	transfer NET_RENAME
   141                                  %ELSE
   142                                  multNET equ MultNET	; NASM port equate
   143 00000005 B81111                  	MOV	AX,(multNET << 8) | 17
   144 00000008 CD2F                    	INT	2FH
   145 0000000A C3                      	return
   146                                  %ENDIF
   147                                  
   148                                  LOCAL_RENAME:
   149 0000000B C606[0000]02            	MOV	byte [EXTERR_LOCUS],errLOC_Disk
   150 00000010 8B36[0000]              	MOV	SI,[WFP_START]
   151 00000014 8B3E[0000]              	MOV	DI,[REN_WFP]
   152 00000018 8A04                    	MOV	AL,BYTE PTR [SI]
   153 0000001A 8A25                    	MOV	AH,BYTE PTR [DI]
   154 0000001C 0D2020                  	OR	AX,2020H		; Lower case
   155 0000001F 38E0                    	CMP	AL,AH
   156 00000021 7405                    	JZ	SAMEDRV
   157 00000023 B81100                  	MOV	AX,error_not_same_device
   158 00000026 F9                      	STC
   159 00000027 C3                      	return
   160                                  
   161                                  SAMEDRV:
   162 00000028 FF36[0200]              	PUSH	WORD PTR [DMAADD+2]
   163 0000002C FF36[0000]              	PUSH	WORD PTR [DMAADD]
   164 00000030 8C1E[0200]              	MOV	WORD PTR [DMAADD+2],DS
   165 00000034 C706[0000][0000]        	MOV	WORD PTR [DMAADD],OFFSET RENAMEDMA wrt DOSGROUP
   166                                  Found_dev equ FOUND_DEV	; NASM port label
   167 0000003A C606[0000]00            	MOV	byte [Found_dev],0		; Rename fails on DEVS, assume not a dev
   168 0000003F E8(0000)                	EnterCrit   critDisk
   169 00000042 E8(0000)                	invoke	DOS_SEARCH_FIRST	; Sets [NoSetDir] to 1, [CURBUF+2]:BX
   170                                  					;    points to entry
   171                                  Check_Dev equ Check_dev	; NASM port label
   172 00000045 7315                    	JNC	Check_Dev
   173 00000047 83F812                  	CMP	AX,error_no_more_files
   174 0000004A 7503                    	JNZ	GOTERR
   175 0000004C B80200                  	MOV	AX,error_file_not_found
   176                                  GOTERR:
   177 0000004F F9                      	STC
   178                                  RENAME_POP:
   179 00000050 8F06[0000]              	POP	WORD PTR [DMAADD]
   180 00000054 8F06[0200]              	POP	WORD PTR [DMAADD+2]
   181 00000058 E8(0000)                	LeaveCrit   critDisk
   182 0000005B C3                      	return
   183                                  
   184                                  Check_dev:
   185 0000005C B80500                  	MOV	AX,error_access_denied	; Assume error
   186                                  
   187 0000005F 1E                      	PUSH	DS			      ;PTM.				;AN000;
   188 00000060 C536[0000]              	LDS	SI,[DMAADD]		      ;PTM.  chek if source a dir	;AN000;
   189                                   assume ds:DOSGROUP
   190                                  		; lDOS note: This code actually exists in MS-DOS v5
   191                                  		;  and v7.10 unchanged. DS happens to be DOSGROUP here
   192                                  		;  because DMAADD was overwritten before this.
   193 00000064 83C615                  	ADD	SI,find_buf_attr	      ;PTM.				;AN000;
   194 00000067 F6440B10                	TEST	byte [SI + dir_attr],attr_directory  ;PTM.				;AN000;
   195 0000006B 7407                    	JZ	notdir			      ;PTM.				;AN000;
   196 0000006D 8B36[0000]              	MOV	SI,[REN_WFP]		      ;PTM.  if yes, make sure path	;AN000;
   197 00000071 E8(0000)                	invoke	Check_Pathlen2		      ;PTM.   length < 67		;AN000;
   198                                  notdir:
   199 00000074 1F                      	POP	DS			      ;PTM.				;AN000;
   200                                   assume ds:DOSGROUP
   201 00000075 77D8                    	JA	GOTERR			      ;PTM.				;AN000;
   202                                  
   203 00000077 803E[0000]00            	CMP	byte [Found_dev],0
   204 0000007C 75D1                    	JNZ	GOTERR
   205                                  ; At this point a source has been found.  There is search continuation info (a
   206                                  ; la DOS_SEARCH_NEXT) for the source at RENAMEDMA, together with the first
   207                                  ; directory entry found.
   208                                  ; [THISCDS], [THISDPB], and [THISDRV] are set and will remain correct
   209                                  ; throughout the RENAME since it is known at this point that the source and
   210                                  ; destination are both on the same device.
   211                                  ; [SATTRIB] is also set.
   212 0000007E 89DE                    	MOV	SI,BX
   213 00000080 83C61A                  	ADD	SI,dir_first
   214 00000083 E8(0000)                	invoke	REN_DEL_Check
   215 00000086 7305                    	JNC	REN_OK1
   216 00000088 B82000                  	MOV	AX,error_sharing_violation
   217 0000008B EBC3                    	JMP	RENAME_POP
   218                                  
   219                                  REN_OK1:				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   220 0000008D E8(0000)                	invoke	FastOpen_Delete 	; delete dir info in fastopen DOS 3.3
   221 00000090 8B36[0000]              	MOV	SI,[REN_WFP]		; Swap source and destination
   222 00000094 8936[0000]              	MOV	[WFP_START],SI
   223 00000098 C706[0000]FFFF          	MOV	word [CURR_DIR_END],-1	; No current dir on dest
   224 0000009E C706[0000]FFE5          	MOV	WORD PTR [CREATING],0E5FFH  ; Creating, not DEL *.*
   225                                  					; A rename is like a CREATE_NEW as far
   226                                  					; as the destination is concerned.
   227 000000A4 E8(0000)                	invoke	GetPathNoSet
   228                                  ;   If this Getpath fails due to file not found, we know all renames will work
   229                                  ;   since no files match the destination name.	If it fails for any other
   230                                  ;   reason, the rename fails on a path not found, or whatever (also fails if
   231                                  ;   we find a device or directory).  If the Getpath succeeds, we aren't sure
   232                                  ;   if the rename should fail because we haven't built an explicit name by
   233                                  ;   substituting for the meta chars in it.  In this case the destination file
   234                                  ;   spec with metas is in [NAME1] and the explicit source name is at RENAMEDMA
   235                                  ;   in the directory entry part.
   236 000000A7 7221                    	JC	NODEST
   237                                  ;;	JZ	BAD_ACC 		; Dest string is a directory		;AC000;
   238 000000A9 08E4                    	OR	AH,AH			; Device?
   239 000000AB 7931                    	JNS	SAVEDEST		; No, continue
   240                                  BAD_ACC:
   241 000000AD B80500                  	MOV	AX,error_access_denied
   242 000000B0 F9                      	STC
   243                                  RENAME_CLEAN:
   244 000000B1 9C                      	PUSHF				; Save carry state
   245 000000B2 50                      	PUSH	AX			; and error code (if carry set)
   246 000000B3 A0[0000]                	MOV	AL,[THISDRV]
   247 000000B6 E8(0000)                	invoke	FLUSHBUF
   248 000000B9 58                      	POP	AX
   249 000000BA 803E[0000]00            	CMP	byte [FAILERR],0
   250 000000BF 7503                    	JNZ	BAD_ERR 		; User FAILed to I 24
   251 000000C1 9D                      	POPF
   252 000000C2 EB8C                    	JMP	RENAME_POP
   253                                  
   254                                  BAD_ERR:
   255 000000C4 58                      	POP	AX			; Saved flags
   256 000000C5 B80300                  	MOV	AX,error_path_not_found
   257 000000C8 EB85                    	JMP	GOTERR
   258                                  
   259                                  NODEST:
   260 000000CA 750B                    	JNZ	BAD_PATH
   261 000000CC 803E[0000]00            	CMP	byte [FAILERR],0
   262 000000D1 7504                    	JNZ	BAD_PATH	; Search for dest failed because user FAILed on
   263                                  				;	I 24
   264 000000D3 08C9                    	OR	CL,CL
   265 000000D5 7507                    	JNZ	SAVEDEST
   266                                  BAD_PATH:
   267 000000D7 B80300                  	MOV	AX,error_path_not_found
   268 000000DA F9                      	STC
   269 000000DB E972FF                  	JMP	RENAME_POP
   270                                  
   271                                  SAVEDEST:
   272 000000DE 1607                    	Context ES
   273 000000E0 BF[0000]                	MOV	DI,OFFSET NAME2 wrt DOSGROUP
   274 000000E3 BE[0000]                	MOV	SI,OFFSET NAME1 wrt DOSGROUP
   275 000000E6 B90B00                  	MOV	CX,11
   276 000000E9 F3A4                    	REP	MOVSB			; Save dest with metas at NAME2
   277 000000EB A1[0000]                	MOV	AX,[DIRSTART]
   278 000000EE A3[0000]                	MOV	[DESTSTART],AX
   279                                  BUILDDEST:
   280 000000F1 1607                    	Context ES			; needed due to JMP BUILDDEST below
   281 000000F3 BB[1500]                	MOV	BX,OFFSET RENAMEDMA + 21 wrt DOSGROUP   ; Source of replace chars
   282 000000F6 BF[0000]                	MOV	DI,OFFSET NAME1 wrt DOSGROUP    ; Real dest name goes here
   283 000000F9 BE[0000]                	MOV	SI,OFFSET NAME2 wrt DOSGROUP    ; Raw dest
   284 000000FC B90B00                  	MOV	CX,11
   285 000000FF E8F400                  	CALL	NEW_RENAME		    ;IFS. replace ? chars		;AN000;
   286                                  
   287 00000102 C606[0000]16            	MOV	byte [ATTRIB],attr_all	; Stop duplicates with any attributes
   288 00000107 C606[0000]FF            	MOV	byte [CREATING],0FFH
   289 0000010C E8(0000)                	invoke	DEVNAME 		; Check if we built a device name
   290                                  	ASSUME	ES:NOTHING
   291 0000010F 739C                    	JNC	BAD_ACC
   292 00000111 8B1E[0000]              	MOV	BX,[DESTSTART]
   293 00000115 C42E[0000]              	LES	BP,[THISDPB]
   294 00000119 E8(0000)                	invoke	SetDirSrch		; Reset search to start of dir
   295 0000011C 728F                    	JC	BAD_ACC 		; Screw up
   296 0000011E E8(0000)                	invoke	FINDENTRY		; See if new name already exists
   297 00000121 738A                    	JNC	BAD_ACC 		; Error if found
   298 00000123 803E[0000]00            	CMP	byte [FAILERR],0
   299 00000128 752A                    	JNZ	BAD_ACCJ		; Find failed because user FAILed to I 24
   300 0000012A A1[0000]                	MOV	AX,[DESTSTART]		; DIRSTART of dest
   301 0000012D 3B06[0F00]              	CMP	AX,WORD PTR [RENAMEDMA + 15]	; DIRSTART of source
   302 00000131 745D                    	JZ	SIMPLE_RENAME		; If =, just give new name
   303                                  
   304 00000133 A0[2000]                	MOV	AL,[RENAMEDMA + 21 + dir_attr]
   305 00000136 A810                    	TEST	AL,attr_directory
   306 00000138 751A                    	JNZ	BAD_ACCJ		; Can only do a simple rename on dirs,
   307                                  					; otherwise the .  and ..  entries get
   308                                  					; wiped.
   309 0000013A A2[0000]                	MOV	[ATTRIB],AL
   310 0000013D 8C1E[0200]              	MOV	WORD PTR [THISSFT+2],DS
   311                                  SF_ENTRY_struc_size equ sf_entry_struc_size	; NASM port equate
   312 00000141 BE[C5FF]                	MOV	SI,OFFSET AUXSTACK - SF_ENTRY_struc_size wrt DOSGROUP
   313 00000144 8936[0000]              	MOV	WORD PTR [THISSFT],SI
   314 00000148 C744020200              	MOV	word [SI + sf_mode],sharing_compat+open_for_both
   315 0000014D 31C9                    	XOR	CX,CX			; Set "device ID" for call into makenode
   316 0000014F E8(0000)                	invoke	RENAME_MAKE		; This is in mknode
   317 00000152 7303                    	JNC	GOT_DEST
   318                                  BAD_ACCJ:
   319 00000154 E956FF                  	JMP	BAD_ACC
   320                                  
   321                                  GOT_DEST:
   322 00000157 53                      	SaveReg <BX>
   323                                  ThisSFT equ THISSFT	; NASM port label
   324 00000158 C43E[0000]              	LES	DI,[ThisSFT]		; Rename_make entered this into sharing
   325 0000015C E8(0000)                	Invoke	ShareEnd		; we need to remove it.
   326 0000015F 5B                      	RestoreReg  <BX>
   327                                  ; A zero length entry with the correct new name has now been made at
   328                                  ;   [CURBUF+2]:BX.
   329 00000160 C43E[0000]              	LES	DI,[CURBUF]
   330                                  	Assert	ISBUF,<ES,DI>,"Got_Dest"
   331                                  
   332 00000164 26F6450540              	TEST	byte [ES:DI + buf_flags],buf_dirty  ;LB. if already dirty		;AN000;
   333 00000169 7508                    	JNZ	yesdirty		  ;LB.	  don't increment dirty count   ;AN000;
   334 0000016B E8(0000)                	invoke	INC_DIRTY_COUNT 	  ;LB.					;AN000;
   335 0000016E 26804D0540              	OR	byte [ES:DI + buf_flags],buf_dirty
   336                                  yesdirty:
   337 00000173 89DF                    	MOV	DI,BX
   338 00000175 83C70B                  	ADD	DI,dir_attr		; Skip name
   339 00000178 BE[2000]                	MOV	SI,OFFSET RENAMEDMA + 21 + dir_attr wrt DOSGROUP
   340 0000017B B91500                  	MOV	CX,(dir_entry_struc_size) - dir_attr
   341 0000017E F3A4                    	REP	MOVSB
   342 00000180 E85B00                  	CALL	GET_SOURCE
   343 00000183 7255                    	JC	RENAME_OVER
   344 00000185 89DF                    	MOV	DI,BX
   345 00000187 8E06[0200]              	MOV	ES,WORD PTR [CURBUF+2]
   346                                   assume es:nothing
   347 0000018B B0E5                    	MOV	AL,0E5H
   348 0000018D AA                      	STOSB				; "free" the source
   349 0000018E EB13                    	JMP	SHORT DIRTY_IT
   350                                  
   351                                  SIMPLE_RENAME:
   352 00000190 E84B00                  	CALL	GET_SOURCE		; Get the source back
   353 00000193 7245                    	JC	RENAME_OVER
   354 00000195 89DF                    	MOV	DI,BX
   355 00000197 8E06[0200]              	MOV	ES,WORD PTR [CURBUF+2]
   356                                   assume es:nothing
   357 0000019B BE[0000]                	MOV	SI,OFFSET NAME1 wrt DOSGROUP    ; New Name
   358 0000019E B90B00                  	MOV	CX,11
   359 000001A1 F3A4                    	REP	MOVSB
   360                                  DIRTY_IT:
   361 000001A3 8B3E[0000]              	MOV	DI,WORD PTR [CURBUF]
   362                                  
   363 000001A7 26F6450540              	TEST	byte [ES:DI + buf_flags],buf_dirty  ;LB. if already dirty		;AN000;
   364 000001AC 7508                    	JNZ	yesdirty2		  ;LB.	  don't increment dirty count   ;AN000;
   365 000001AE E8(0000)                	invoke	INC_DIRTY_COUNT 	  ;LB.					;AN000;
   366 000001B1 26804D0540              	OR	byte [ES:DI + buf_flags],buf_dirty
   367                                  yesdirty2:
   368                                  	Assert	ISBUF,<ES,DI>,"Dirty_it"
   369                                  NEXT_SOURCE:
   370 000001B6 BE[0100]                	MOV	SI,OFFSET RENAMEDMA + 1 wrt DOSGROUP    ;Name
   371                                  ;
   372                                  ; WARNING!  Rename_Next leaves the disk critical section *ALWAYS*.  We need
   373                                  ; to enter it before going to RENAME_Next.
   374                                  ;
   375 000001B9 E8(0000)                	EnterCrit   critDisk
   376 000001BC C606[0000]00            	MOV	byte [CREATING],0	; Correct setting for search (we changed it
   377                                  				;   to FF when we made the prev new file).
   378 000001C1 E8(0000)                	invoke	RENAME_NEXT
   379                                  ;
   380                                  ; Note, now, that we have exited the previous ENTER and so are back to where
   381                                  ; we were before.
   382                                  ;
   383 000001C4 7214                    	JC	RENAME_OVER
   384                                  dir_First equ dir_first	; NASM port equate
   385 000001C6 8D771A                  	LEA	SI,[BX + dir_First]
   386 000001C9 E8(0000)                	invoke	REN_DEL_Check
   387 000001CC 7306                    	JNC	REN_OK2
   388 000001CE B82000                  	MOV	AX,error_sharing_violation
   389 000001D1 E9DDFE                  	JMP	RENAME_CLEAN
   390                                  
   391                                  REN_OK2:				;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   392 000001D4 E8(0000)                	invoke	FastOpen_Delete 	; delete dir info in fastopen DOS 3.3
   393 000001D7 E917FF                  	JMP	BUILDDEST
   394                                  
   395                                  RENAME_OVER:
   396 000001DA F8                      	CLC
   397 000001DB E9D3FE                  	JMP	RENAME_CLEAN
   398                                  
   399                                  ; Inputs:
   400                                  ;	RENAMEDMA has source info
   401                                  ; Function:
   402                                  ;	Re-find the source
   403                                  ; Output:
   404                                  ;	[CURBUF] set
   405                                  ;	[CURBUF+2]:BX points to entry
   406                                  ;	Carry set if error (currently user FAILed to I 24)
   407                                  ; DS preserved, others destroyed
   408                                  
   409                                  GET_SOURCE:
   410                                  	DOSAssume   CS,<DS>,"Get_Source"
   411                                  	ASSUME	ES:NOTHING
   412                                  
   413 000001DE 8B1E[0F00]              	MOV	BX,WORD PTR [RENAMEDMA + 15]	; DirStart
   414                                  ThisDPB equ THISDPB	; NASM port label
   415 000001E2 C42E[0000]              	LES	BP,[ThisDPB]
   416 000001E6 E8(0000)                	invoke	SetDirSrch
   417 000001E9 7301C3                  	retc
   418 000001EC E8(0000)                	invoke	StartSrch
   419 000001EF A1[0D00]                	MOV	AX,WORD PTR [RENAMEDMA + 13]	; Lastent
   420 000001F2 E8(0000)                	invoke	GetEnt
   421 000001F5 C3                      	return
   422                                  
   423                                  EndProc DOS_RENAME
   424                                  
   425                                  ;Input: DS:SI -> raw string with ?
   426                                  ;	ES:DI -> destination string
   427                                  ;	DS:BX -> source string
   428                                  ;Function: replace ? chars of raw string with chars in source string and
   429                                  ;	   put in destination string
   430                                  ;Output: ES:DI-> new string
   431                                  
   432                                  
   433                                  
   434                                  	procedure   NEW_RENAME,NEAR
   434          ******************       warning: proc NEW_RENAME... [-w+user]
   435                                  	DOSAssume   CS,<DS>,"DOS_Rename"
   436                                  	ASSUME	ES:NOTHING
   437                                  NEWNAM:
   438 000001F6 AC                      	LODSB
   439 000001F7 3C3F                    	CMP	AL,"?"
   440 000001F9 7502                    	JNZ	NOCHG
   441 000001FB 8A07                    	MOV	AL,[BX] 		; Get replace char
   442                                  NOCHG:
   443 000001FD AA                      	STOSB
   444 000001FE 43                      	INC	BX			; Next replace char
   445 000001FF E2F5                    	LOOP	NEWNAM
   446 00000201 C3                      	return
   447                                  
   448                                  EndProc NEW_RENAME
   449                                  
   450                                      END
