started writing qse_fs_mkdir()
This commit is contained in:
		| @ -47,6 +47,7 @@ libqsecmn_la_SOURCES = \ | ||||
| 	fs.c \ | ||||
| 	fs-delete.c \ | ||||
| 	fs-err.c \ | ||||
| 	fs-make.c \ | ||||
| 	fs-move.c \ | ||||
| 	glob.c \ | ||||
| 	hton.c \ | ||||
|  | ||||
| @ -108,28 +108,28 @@ libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ | ||||
| am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \ | ||||
| 	alg-sort.c assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c \ | ||||
| 	fma.c fmt-intmax.c fmt-out.c fs.c fs-delete.c fs-err.c \ | ||||
| 	fs-move.c glob.c hton.c ipad.c lda.c main.c mb8.c mbwc.c \ | ||||
| 	mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c nwif-cfg.c \ | ||||
| 	nwio.c oht.c opt.c path-base.c path-canon.c pio.c pma.c rbt.c \ | ||||
| 	rex.c sck.c sio.c sll.c slmb.c str-beg.c str-cat.c str-chr.c \ | ||||
| 	str-cnv.c str-cmp.c str-cpy.c str-del.c str-dup.c str-dyn.c \ | ||||
| 	str-end.c str-excl.c str-fcpy.c str-fmt.c str-fnmat.c \ | ||||
| 	str-incl.c str-join.c str-len.c str-pac.c str-pbrk.c str-put.c \ | ||||
| 	str-rev.c str-rot.c str-set.c str-spl.c str-spn.c str-str.c \ | ||||
| 	str-subst.c str-tok.c str-trm.c str-word.c task.c time.c tio.c \ | ||||
| 	tmr.c tre.c tre-ast.c tre-compile.c tre-match-bt.c \ | ||||
| 	tre-match-pa.c tre-parse.c tre-stack.c uri.c utf8.c xma.c \ | ||||
| 	uni.c cp949.c cp950.c | ||||
| 	fs-make.c fs-move.c glob.c hton.c ipad.c lda.c main.c mb8.c \ | ||||
| 	mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c \ | ||||
| 	nwif-cfg.c nwio.c oht.c opt.c path-base.c path-canon.c pio.c \ | ||||
| 	pma.c rbt.c rex.c sck.c sio.c sll.c slmb.c str-beg.c str-cat.c \ | ||||
| 	str-chr.c str-cnv.c str-cmp.c str-cpy.c str-del.c str-dup.c \ | ||||
| 	str-dyn.c str-end.c str-excl.c str-fcpy.c str-fmt.c \ | ||||
| 	str-fnmat.c str-incl.c str-join.c str-len.c str-pac.c \ | ||||
| 	str-pbrk.c str-put.c str-rev.c str-rot.c str-set.c str-spl.c \ | ||||
| 	str-spn.c str-str.c str-subst.c str-tok.c str-trm.c str-word.c \ | ||||
| 	task.c time.c tio.c tmr.c tre.c tre-ast.c tre-compile.c \ | ||||
| 	tre-match-bt.c tre-match-pa.c tre-parse.c tre-stack.c uri.c \ | ||||
| 	utf8.c xma.c uni.c cp949.c cp950.c | ||||
| @ENABLE_BUNDLED_UNICODE_TRUE@am__objects_1 = uni.lo | ||||
| @ENABLE_XCMGRS_TRUE@am__objects_2 = cp949.lo cp950.lo | ||||
| am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \ | ||||
| 	alg-sort.lo assert.lo chr.lo dir.lo dll.lo env.lo gdl.lo \ | ||||
| 	htb.lo fio.lo fma.lo fmt-intmax.lo fmt-out.lo fs.lo \ | ||||
| 	fs-delete.lo fs-err.lo fs-move.lo glob.lo hton.lo ipad.lo \ | ||||
| 	lda.lo main.lo mb8.lo mbwc.lo mbwc-str.lo mem.lo mux.lo \ | ||||
| 	nwad.lo nwad-skad.lo nwif.lo nwif-cfg.lo nwio.lo oht.lo opt.lo \ | ||||
| 	path-base.lo path-canon.lo pio.lo pma.lo rbt.lo rex.lo sck.lo \ | ||||
| 	sio.lo sll.lo slmb.lo str-beg.lo str-cat.lo str-chr.lo \ | ||||
| 	fs-delete.lo fs-err.lo fs-make.lo fs-move.lo glob.lo hton.lo \ | ||||
| 	ipad.lo lda.lo main.lo mb8.lo mbwc.lo mbwc-str.lo mem.lo \ | ||||
| 	mux.lo nwad.lo nwad-skad.lo nwif.lo nwif-cfg.lo nwio.lo oht.lo \ | ||||
| 	opt.lo path-base.lo path-canon.lo pio.lo pma.lo rbt.lo rex.lo \ | ||||
| 	sck.lo sio.lo sll.lo slmb.lo str-beg.lo str-cat.lo str-chr.lo \ | ||||
| 	str-cnv.lo str-cmp.lo str-cpy.lo str-del.lo str-dup.lo \ | ||||
| 	str-dyn.lo str-end.lo str-excl.lo str-fcpy.lo str-fmt.lo \ | ||||
| 	str-fnmat.lo str-incl.lo str-join.lo str-len.lo str-pac.lo \ | ||||
| @ -414,19 +414,19 @@ noinst_HEADERS = \ | ||||
|  | ||||
| libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \ | ||||
| 	assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c fma.c \ | ||||
| 	fmt-intmax.c fmt-out.c fs.c fs-delete.c fs-err.c fs-move.c \ | ||||
| 	glob.c hton.c ipad.c lda.c main.c mb8.c mbwc.c mbwc-str.c \ | ||||
| 	mem.c mux.c nwad.c nwad-skad.c nwif.c nwif-cfg.c nwio.c oht.c \ | ||||
| 	opt.c path-base.c path-canon.c pio.c pma.c rbt.c rex.c sck.c \ | ||||
| 	sio.c sll.c slmb.c str-beg.c str-cat.c str-chr.c str-cnv.c \ | ||||
| 	str-cmp.c str-cpy.c str-del.c str-dup.c str-dyn.c str-end.c \ | ||||
| 	str-excl.c str-fcpy.c str-fmt.c str-fnmat.c str-incl.c \ | ||||
| 	str-join.c str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c \ | ||||
| 	str-rot.c str-set.c str-spl.c str-spn.c str-str.c str-subst.c \ | ||||
| 	str-tok.c str-trm.c str-word.c task.c time.c tio.c tmr.c tre.c \ | ||||
| 	tre-ast.c tre-compile.c tre-match-bt.c tre-match-pa.c \ | ||||
| 	tre-parse.c tre-stack.c uri.c utf8.c xma.c $(am__append_1) \ | ||||
| 	$(am__append_2) | ||||
| 	fmt-intmax.c fmt-out.c fs.c fs-delete.c fs-err.c fs-make.c \ | ||||
| 	fs-move.c glob.c hton.c ipad.c lda.c main.c mb8.c mbwc.c \ | ||||
| 	mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c nwif-cfg.c \ | ||||
| 	nwio.c oht.c opt.c path-base.c path-canon.c pio.c pma.c rbt.c \ | ||||
| 	rex.c sck.c sio.c sll.c slmb.c str-beg.c str-cat.c str-chr.c \ | ||||
| 	str-cnv.c str-cmp.c str-cpy.c str-del.c str-dup.c str-dyn.c \ | ||||
| 	str-end.c str-excl.c str-fcpy.c str-fmt.c str-fnmat.c \ | ||||
| 	str-incl.c str-join.c str-len.c str-pac.c str-pbrk.c str-put.c \ | ||||
| 	str-rev.c str-rot.c str-set.c str-spl.c str-spn.c str-str.c \ | ||||
| 	str-subst.c str-tok.c str-trm.c str-word.c task.c time.c tio.c \ | ||||
| 	tmr.c tre.c tre-ast.c tre-compile.c tre-match-bt.c \ | ||||
| 	tre-match-pa.c tre-parse.c tre-stack.c uri.c utf8.c xma.c \ | ||||
| 	$(am__append_1) $(am__append_2) | ||||
| libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined | ||||
| libqsecmn_la_LIBADD = $(SOCKET_LIBS) $(QUADMATH_LIBS) | ||||
| @ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \ | ||||
| @ -530,6 +530,7 @@ distclean-compile: | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt-out.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-delete.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-err.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-make.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-move.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdl.Plo@am__quote@ | ||||
|  | ||||
							
								
								
									
										130
									
								
								qse/lib/cmn/fs-make.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								qse/lib/cmn/fs-make.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,130 @@ | ||||
| /*  | ||||
|  * $Id$ | ||||
|  * | ||||
|     Copyright (c) 2006-2014 Chung, Hyung-Hwan. All rights reserved. | ||||
|  | ||||
|     Redistribution and use in source and binary forms, with or without | ||||
|     modification, are permitted provided that the following conditions | ||||
|     are met: | ||||
|     1. Redistributions of source code must retain the above copyright | ||||
|        notice, this list of conditions and the following disclaimer. | ||||
|     2. Redistributions in binary form must reproduce the above copyright | ||||
|        notice, this list of conditions and the following disclaimer in the | ||||
|        documentation and/or other materials provided with the distribution. | ||||
|  | ||||
|     THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR | ||||
|     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
|     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
|     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
|     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
|     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
|     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
|     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
|     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
|     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  */ | ||||
|  | ||||
| #include "fs.h" | ||||
|  | ||||
| static int make_directory_in_fs (qse_fs_t* fs, const qse_fs_char_t* fspath) | ||||
| { | ||||
|  | ||||
| #if defined(_WIN32) | ||||
|  | ||||
| 	if (CreateDirectory (fspath, QSE_NULL) == FALSE) | ||||
| 	{ | ||||
| 		fs->errnum = qse_fs_syserrtoerrnum (fs, GetLastError()); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| #elif defined(__OS2__) | ||||
|  | ||||
| 	APIRET rc; | ||||
|  | ||||
| 	rc = DosMkDir (fspath); | ||||
| 	if (rc != NO_ERROR) | ||||
| 	{ | ||||
| 		fs->errnum = qse_fs_syserrtoerrnum (fs, rc); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| #elif defined(__DOS__) | ||||
|  | ||||
| 	if (mkdir (fspath) <= -1) | ||||
| 	{ | ||||
| 		fs->errnum = qse_fs_syserrtoerrnum (fs, errno); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| #else | ||||
|  | ||||
| 	if (QSE_MKDIR (fspath, 0755) <= -1) | ||||
| 	{ | ||||
| 		fs->errnum = qse_fs_syserrtoerrnum (fs, errno); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| #endif | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| /* --------------------------------------------------------------------- */ | ||||
|  | ||||
| static int make_directory_with_mbs (qse_fs_t* fs, const qse_mchar_t* path) | ||||
| { | ||||
| 	qse_fs_char_t* fspath; | ||||
| 	int ret; | ||||
|  | ||||
| 	if (fs->cbs.mk)  | ||||
| 	{ | ||||
| 		 | ||||
| 		int x; | ||||
| 		x = fs->cbs.del (fs, path); | ||||
| 		if (x <= -1) return -1; | ||||
| 		if (x == 0) return 0; /* skipped */ | ||||
| 	} | ||||
|  | ||||
| 	fspath = qse_fs_makefspath(fs, path); | ||||
| 	if (!fspath) return -1; | ||||
|  | ||||
| 	ret = delete_file_from_fs (fs, fspath); | ||||
| 	qse_fs_freefspath (fs, path, fspath); | ||||
|  | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
|  | ||||
| static int make_directory_with_wcs (qse_fs_t* fs, const qse_wchar_t* path) | ||||
| { | ||||
| 	qse_fs_char_t* fspath; | ||||
| 	int ret; | ||||
|  | ||||
| 	if (fs->cbs.mk)  | ||||
| 	{ | ||||
| 		int x; | ||||
| 		x = fs->cbs.del (fs, path); | ||||
| 		if (x <= -1) return -1; | ||||
| 		if (x == 0) return 0; /* skipped */ | ||||
| 	} | ||||
|  | ||||
| 	fspath = qse_fs_makefspath(fs, path); | ||||
| 	if (!fspath) return -1; | ||||
|  | ||||
| 	ret = delete_file_from_fs (fs, fspath); | ||||
| 	qse_fs_freefspath (fs, path, fspath); | ||||
|  | ||||
| 	return ret; | ||||
| } | ||||
|  | ||||
| /* --------------------------------------------------------------------- */ | ||||
| int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path) | ||||
| { | ||||
|  | ||||
| 	return 0; | ||||
| } | ||||
|  | ||||
| int qse_fs_mkdirwcs (qse_fs_t* fs, const qse_wchar_t* path) | ||||
| { | ||||
| 	return 0; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user