mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 10:11:48 +00:00
Added platform independant mkdir program
svn path=/trunk/; revision=1322
This commit is contained in:
parent
acaf5099d7
commit
8293c58f61
2 changed files with 125 additions and 32 deletions
|
@ -68,7 +68,17 @@ rcopy$(EXE_POSTFIX): rcopy.c
|
|||
$(NATIVE_CC) -g -DDOS_PATHS rcopy.c -o rcopy$(EXE_POSTFIX)
|
||||
endif
|
||||
|
||||
install: rcopy$(EXE_POSTFIX) make_install_dirs autoexec_install $(COMPONENTS:%=%_install) \
|
||||
ifeq ($(HOST),mingw32-linux)
|
||||
rmkdir$(EXE_POSTFIX): rmkdir.c
|
||||
$(NATIVE_CC) -g -DUNIX_PATHS rmkdir.c -o rmkdir$(EXE_POSTFIX)
|
||||
endif
|
||||
ifeq ($(HOST),mingw32-windows)
|
||||
rmkdir$(EXE_POSTFIX): rmkdir.c
|
||||
$(NATIVE_CC) -g -DDOS_PATHS rmkdir.c -o rmkdir$(EXE_POSTFIX)
|
||||
endif
|
||||
|
||||
|
||||
install: rcopy$(EXE_POSTFIX) rmkdir$(EXE_POSTFIX) make_install_dirs autoexec_install $(COMPONENTS:%=%_install) \
|
||||
$(DLLS:%=%_install) $(LOADERS:%=%_install) \
|
||||
$(KERNEL_SERVICES:%=%_install) $(SUBSYS:%=%_install) \
|
||||
$(APPS:%=%_install)
|
||||
|
@ -277,33 +287,19 @@ $(SUBSYS:%=%_dist): %_dist:
|
|||
#
|
||||
# Make an install floppy
|
||||
#
|
||||
|
||||
install: all
|
||||
./install.sh /mnt/hda1
|
||||
./install.sh /mnt/hda4
|
||||
./install.bochs
|
||||
|
||||
make_install_dirs:
|
||||
ifeq ($(DOSCLI),yes)
|
||||
mkdir $(FLOPPY_DIR)\dlls
|
||||
mkdir $(FLOPPY_DIR)\apps
|
||||
mkdir $(FLOPPY_DIR)\drivers
|
||||
mkdir $(FLOPPY_DIR)\subsys
|
||||
else
|
||||
mkdir $(FLOPPY_DIR)/dlls $(FLOPPY_DIR)/apps $(FLOPPY_DIR)/drivers
|
||||
mkdir $(FLOPPY_DIR)/subsys
|
||||
endif
|
||||
./rmkdir $(FLOPPY_DIR)/dlls
|
||||
./rmkdir $(FLOPPY_DIR)/apps
|
||||
./rmkdir $(FLOPPY_DIR)/drivers
|
||||
./rmkdir $(FLOPPY_DIR)/subsys
|
||||
|
||||
|
||||
.PHONY: make_install_dirs
|
||||
|
||||
autoexec_install: $(FLOPPY_DIR)/autoexec.bat
|
||||
|
||||
$(FLOPPY_DIR)/autoexec.bat: bootflop.bat
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) bootflop.bat $(FLOPPY_DIR)\autoexec.bat
|
||||
else
|
||||
$(CP) bootflop.bat $(FLOPPY_DIR)/autoexec.bat
|
||||
endif
|
||||
|
||||
#
|
||||
# Make a distribution saveset
|
||||
|
@ -324,18 +320,13 @@ else
|
|||
$(RM) -r $(DIST_DIR)
|
||||
endif
|
||||
|
||||
make_dist_dirs:
|
||||
ifeq ($(DOSCLI),yes)
|
||||
mkdir $(DIST_DIR)
|
||||
mkdir $(DIST_DIR)\dlls
|
||||
mkdir $(DIST_DIR)\apps
|
||||
mkdir $(DIST_DIR)\drivers
|
||||
mkdir $(DIST_DIR)\dlls
|
||||
mkdir $(DIST_DIR)\subsys
|
||||
else
|
||||
mkdir $(DIST_DIR) $(DIST_DIR)/dlls $(DIST_DIR)/apps $(DIST_DIR)/drivers
|
||||
mkdir $(DIST_DIR)/subsys
|
||||
endif
|
||||
make_dist_dirs: ./rmkdir
|
||||
./rmkdir $(DIST_DIR)
|
||||
./rmkdir $(DIST_DIR)/dlls
|
||||
./rmkdir $(DIST_DIR)/apps
|
||||
./rmkdir $(DIST_DIR)/drivers
|
||||
./rmkdir $(DIST_DIR)/dlls
|
||||
./rmkdir $(DIST_DIR)/subsys
|
||||
|
||||
.PHONY: clean_dist_dir make_dist_dirs
|
||||
|
||||
|
|
102
reactos/rmkdir.c
Normal file
102
reactos/rmkdir.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char* convert_path(char* origpath)
|
||||
{
|
||||
char* newpath;
|
||||
int i;
|
||||
|
||||
newpath = strdup(origpath);
|
||||
|
||||
i = 0;
|
||||
while (newpath[i] != 0)
|
||||
{
|
||||
#ifdef UNIX_PATHS
|
||||
if (newpath[i] == '\\')
|
||||
{
|
||||
newpath[i] = '/';
|
||||
}
|
||||
#else
|
||||
#ifdef DOS_PATHS
|
||||
if (newpath[i] == '/');
|
||||
{
|
||||
newpath[i] = '\\';
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
i++;
|
||||
}
|
||||
return(newpath);
|
||||
}
|
||||
|
||||
#define TRANSFER_SIZE (65536)
|
||||
|
||||
int mkdir_p(char* path)
|
||||
{
|
||||
if (chdir(path) == 0)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
#ifdef UNIX_PATHS
|
||||
if (mkdir(path, 0755) != 0)
|
||||
{
|
||||
perror("Failed to create directory");
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
if (mkdir(path) != 0)
|
||||
{
|
||||
perror("Failed to create directory");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (chdir(path) != 0)
|
||||
{
|
||||
perror("Failed to change directory");
|
||||
exit(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* path1;
|
||||
FILE* in;
|
||||
FILE* out;
|
||||
char* csec;
|
||||
int is_abs_path;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Too many arguments\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
path1 = convert_path(argv[1]);
|
||||
|
||||
if (isalpha(path1[0]) && path1[1] == ':' && path1[2] == '/')
|
||||
{
|
||||
csec = strtok(path1, "/");
|
||||
chdir(csec);
|
||||
csec = strtok(NULL, "/");
|
||||
}
|
||||
else if (path1[0] == '/')
|
||||
{
|
||||
chdir("/");
|
||||
csec = strtok(path1, "/");
|
||||
}
|
||||
else
|
||||
{
|
||||
csec = strtok(path1, "/");
|
||||
}
|
||||
|
||||
while (csec != NULL)
|
||||
{
|
||||
mkdir_p(csec);
|
||||
csec = strtok(NULL, "/");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue