diff --git a/src/bin/mv/Makefile b/src/bin/mv/Makefile new file mode 100755 index 0000000..8e71e7d --- /dev/null +++ b/src/bin/mv/Makefile @@ -0,0 +1,45 @@ +# $Id$ +# Application Makefile (C) 2002-2004 The UbixOS Project + +# Include Global 'Source' Options +include ../../Makefile.inc +include ../Makefile.inc + +#Linker +LD = ld + +#Binary File Name +BINARY = mv + +#Delete Program +REMOVE = rm -f + +#Objects +OBJS = main.o + +LIBRARIES = ../../lib/libc_old/libc_old.so + +# Link The Binary +$(BINARY) : $(OBJS) + $(CC) $(CFLAGS) -o $@ $(STARTUP) $(LIBRARIES) $(OBJS) + strip $(BINARY) + +# Compile the source files +.cc.o: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.cc.s: + $(CXX) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.c.o: + $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -c -o $@ $< + +.c.s: + $(CC) -Wall -O $(CFLAGS) $(INCLUDES) -S -o $@ $< + +.S.o: + $(CC) -Wall $(CLFAGS) $(INCLUDES) -c -o $@ $< + +# Clean Up The junk +clean: + $(REMOVE) $(OBJS) $(BINARY) diff --git a/src/bin/mv/main.c b/src/bin/mv/main.c new file mode 100755 index 0000000..c090151 --- /dev/null +++ b/src/bin/mv/main.c @@ -0,0 +1,52 @@ +#include +#include +#include + +int main(int argc,char **argv) +{ + int i = 0x0, z = 0x0; + char *buffer = (char *)malloc(4096); + FILE *in = 0x0; + FILE *out = 0x0; + + if(argc != 3) + { + printf("usage: mv \n"); + return 0; + } + + in = fopen(argv[1],"rb"); + out = fopen(argv[2],"wb"); + + if(in == NULL || out == NULL) + { + printf("unable to open file(s) for i/o\n"); + return 1; + } + while (!feof(in)) + { + i = fread(buffer,4096,1,in); + z = fwrite(buffer,4096,1,out); + } + fclose(in); + fclose(out); + + if(i != z) + printf("mv: failed: out of disk space or kernel error\n"); + else + unlink(argv[1]); + return(0x0); +} + +/*** + $Log$ + Revision 1.4 2005/08/05 09:43:57 fsdfs + + code clean up, performance tuning + + Revision 1.3 2004/05/24 13:40:35 reddawg + Clean Up + + + END + ***/