include	clib.inc
include	wsub.inc
ifdef __DZ__
 include plugins/plugins.inc
endif
ifdef __ZIP__
 include unzip.inc
 include dos.inc
 include time.inc
 include string.inc
 __ARC__ = 1
endif
ifdef __DLL__
 __ARC__ = 1
endif

ifdef __ZIP__

extrn	foreslash:BYTE

_TEXT	SEGMENT

arc_initdirectory:
	mov	__srcfile,0
	push	es
	push	dx
	invoke	strfcat,addr __outfile,es:[bx].ws_path,es:[bx].ws_file
	pop	dx
	pop	es
	invoke	strfcat,addr __outpath,es:[bx].ws_arch,ds::dx
	invoke	strcat,addr __outpath,addr foreslash
	invoke	dostounix,dx::ax
	ret

arc_mkdir:
	call	arc_initdirectory
	push	0
	push	0
	call	dosdate
	push	ax
	call	dostime
	push	ax
	push	_A_SUBDIR
	call	wzipadd
	ret

_TEXT	ENDS

endif

PPROC	wsmkdir, wsub:dword, directory:dword
  ifdef __ARC__
	les	bx,wsub
	les	bx,es:[bx.ws_flag]
	mov	ax,es:[bx]
	and	ax,_W_ARCHIVE
	jnz	wsmkdir_arch
  endif
	invoke	wsmkdirlocal, directory
    wsmkdir_end:
	ret
  ifdef __ARC__
    wsmkdir_arch:
   ifdef __DLL__
	test	ax,_W_ARCHEXT
	jz	@F
	mov	bx,word ptr wsub
	mov	dx,WORD PTR directory+2
	mov	cx,WORD PTR directory
	mov	ah,_DLL_MKDIR
	int	DLL
	jmp	wsmkdir_end
    @@:
   endif
   ifdef __ZIP__
	les	bx,wsub
	mov	dx,WORD PTR directory
	call	arc_mkdir
   endif
	jmp	wsmkdir_end
  endif
PEND	wsmkdir

	END
