include	clib.inc
include	wsub.inc
include	dir.inc
include	disk.inc
include	conio.inc

	public	cp_errorinitsub

PPROC	wsinit, wsub:dword
	push	si
	push	di
	les	di,wsub
	mov	ax,':'
	les	bx,es:[di].ws_path
	cmp	es:[bx],ah
	jz	wsinit_get
	cmp	es:[bx+1],al
	je	wsinit_str
    wsinit_get:
	call	getdrv
	jmp	wsinit_init
    wsinit_str:
	mov	al,es:[bx]
	sub	ax,'A'
    wsinit_init:
	push	ax
	call	_disk_init
	mov	dx,ax
	mov	ah,0Eh
	int	21h
	mov	ax,':'
	les	di,wsub
	les	bx,es:[di].ws_path
	cmp	es:[bx],ah
	jz	wsinit_path
	cmp	es:[bx+1],al
	jnz	wsinit_flag
	invoke	chdir, es::bx
	test	ax,ax
	jz	wsinit_flag
    wsinit_path:
	les	di,wsub
	invoke	fullpath,es:[di].ws_path,0
    wsinit_flag:
	invoke	wssetflag,wsub
	mov	dx,ax
	test	ax,ax
	jnz	wsinit_05
	les	di,wsub
	pushm	es:[di].ws_path
	mov	ax,offset cp_errorinitsub
	call	@ermsg
	add	sp,4
	jmp	wsinit_loc
    wsinit_05:
	cmp	ax,1
	je	wsinit_end
	cmp	ax,3		; network
	mov	ax,1
	je	wsinit_end
    wsinit_loc:
	invoke	wslocal,wsub
    wsinit_end:
	pop	di
	pop	si
	ret
PEND	wsinit

_DATA	SEGMENT
cp_errorinitsub	db 'Error init directory',10,'%s',0
_DATA	ENDS

	END
