[GOOD] BUILD 0.1.0.590 DATE 9/05/2011 AT 2:40 PM

====================================================
Mainly changed: FS.Initrd
+ (kind of) refractored VFS, bugfixed
+ Rewrote 'initrd' file system, fixed many problems
+ Working 'cat' and 'dir' console commands
+ Wrote 'initrd' image write application (for windows), however it may
be bugged
This commit is contained in:
2021-09-14 18:52:47 +03:00
parent caa7718af9
commit 852cf1bb17
71 changed files with 1979 additions and 659 deletions

View File

@ -0,0 +1,5 @@
# This code depends on make tool being used
DEPFILES=$(wildcard $(addsuffix .d, ${OBJECTFILES}))
ifneq (${DEPFILES},)
include ${DEPFILES}
endif

View File

@ -0,0 +1,128 @@
#
# There exist several targets which are by default empty and which can be
# used for execution of your targets. These targets are usually executed
# before and after some main targets. They are:
#
# .build-pre: called before 'build' target
# .build-post: called after 'build' target
# .clean-pre: called before 'clean' target
# .clean-post: called after 'clean' target
# .clobber-pre: called before 'clobber' target
# .clobber-post: called after 'clobber' target
# .all-pre: called before 'all' target
# .all-post: called after 'all' target
# .help-pre: called before 'help' target
# .help-post: called after 'help' target
#
# Targets beginning with '.' are not intended to be called on their own.
#
# Main targets can be executed directly, and they are:
#
# build build a specific configuration
# clean remove built files from a configuration
# clobber remove all built files
# all build all configurations
# help print help mesage
#
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
# .help-impl are implemented in nbproject/makefile-impl.mk.
#
# Available make variables:
#
# CND_BASEDIR base directory for relative paths
# CND_DISTDIR default top distribution directory (build artifacts)
# CND_BUILDDIR default top build directory (object files, ...)
# CONF name of current configuration
# CND_PLATFORM_${CONF} platform name (current configuration)
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
#
# NOCDDL
# Environment
MKDIR=mkdir
CP=cp
CCADMIN=CCadmin
# build
build: .build-post
.build-pre:
# Add your pre 'build' code here...
.build-post: .build-impl
# Add your post 'build' code here...
# clean
clean: .clean-post
.clean-pre:
# Add your pre 'clean' code here...
.clean-post: .clean-impl
# Add your post 'clean' code here...
# clobber
clobber: .clobber-post
.clobber-pre:
# Add your pre 'clobber' code here...
.clobber-post: .clobber-impl
# Add your post 'clobber' code here...
# all
all: .all-post
.all-pre:
# Add your pre 'all' code here...
.all-post: .all-impl
# Add your post 'all' code here...
# build tests
build-tests: .build-tests-post
.build-tests-pre:
# Add your pre 'build-tests' code here...
.build-tests-post: .build-tests-impl
# Add your post 'build-tests' code here...
# run tests
test: .test-post
.test-pre:
# Add your pre 'test' code here...
.test-post: .test-impl
# Add your post 'test' code here...
# help
help: .help-post
.help-pre:
# Add your pre 'help' code here...
.help-post: .help-impl
# Add your post 'help' code here...
# include project implementation makefile
include nbproject/Makefile-impl.mk
# include project make variables
include nbproject/Makefile-variables.mk

View File

@ -0,0 +1,5 @@
build/Debug/MinGW-Windows/commands.o: commands.cpp info.h types.h
info.h:
types.h:

View File

@ -0,0 +1,5 @@
build/Debug/MinGW-Windows/info.o: info.cpp types.h info.h
types.h:
info.h:

View File

@ -0,0 +1,3 @@
build/Debug/MinGW-Windows/main.o: main.cpp types.h
types.h:

View File

@ -0,0 +1,246 @@
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include "info.h"
using namespace std;
struct Node
{
char Name[256];
unsigned Flags;
unsigned Size;
unsigned Offset;
Node* Parent;
vector<Node*> Children;
};
Node Root;
Node* Current;
vector <Node*> list;
unsigned Flags;
FILE* Out;
char* removeQuotes (char* s)
{
if (*s == '"') s = s + 1;
char* tmp = strrchr(s, '"');
if (tmp) *tmp = '\0';
return s;
}
int32 indexOf (char* s)
{
for (int i = 0; i < (int)Current->Children.size(); i++)
if (strcmp(s, Current->Children[i]->Name) == 0) return i;
return -1;
}
void CommandCreate (char** argv, int argc)
{
if (argc < 2) throw ExcSyntaxError;
argv[1] = removeQuotes(argv[1]);
// Set up root
Root.Parent = &Root;
Root.Flags = 0xB68;
Current = &Root;
Flags = 0xB68;
// Open 'root' file
Out = fopen(argv[1], "wb");
if (!Out) throw ExcCannotOpenOutput;
}
void CommandSetFlags (char** argv, int argc)
{
if (argc < 2) throw ExcSyntaxError;
argv[1] = removeQuotes(argv[1]);
unsigned long tmp = strtoul(argv[1], NULL, 0x10);
Flags = (uint32) tmp & 0x497;
}
void CommandAddFile (char** argv, int argc)
{
if (argc < 2) throw ExcSyntaxError;
argv[1] = removeQuotes(argv[1]);
Node* node = new Node();
memset(node, 0, sizeof(Node));
strcpy(node->Name, argv[1]);
node->Flags = Flags | 0x1; // File
node->Parent = Current;
list.push_back(node);
Current->Children.push_back(node);
}
void CommandAddDirectory (char** argv, int argc)
{
if (argc < 2) throw ExcSyntaxError;
argv[1] = removeQuotes(argv[1]);
Node* node = new Node();
memset(node, 0, sizeof(Node));
strcpy(node->Name, argv[1]);
node->Flags = Flags | 0x2; // Directory
node->Parent = Current;
list.push_back(node);
Current->Children.push_back(node);
}
void CommandChangeDirectory (char** argv, int argc)
{
if (argc < 2) throw ExcSyntaxError;
argv[1] = removeQuotes(argv[1]);
if (argv[1][0] == '\0') return;
// See if we need to go to root
if (argv[1][0] == '\\') {
Current = &Root;
argv[1] = argv[1] + 1;
}
// Process every folder in path
while (argv[1])
{
char* next = strchr(argv[1], '\\');
// mark next entry to parse
if (next) { *next = 0; next = next+1; }
// previous dir?
if (strcmp(argv[1], "..") == 0) Current = Current->Parent;
else {
// Find next node
int index = indexOf(argv[1]);
if (index == -1 && strcmp(argv[1], ".") != 0) throw ExcInvalidPath; // Invalid path
// Set as current
Current = Current->Children[index];
}
argv[1] = next;
}
}
unsigned CurrentOffset;
void ProcessNodes(Node* node)
{
for (int i = 0; i < node->Children.size(); i++)
{
// Calculate size & offset
node->Children[i]->Offset = CurrentOffset;
// File
if (node->Children[i]->Flags & 0x1)
node->Children[i]->Size = InfoGetFileSize(node->Children[i]->Name);
// Directory
else
node->Children[i]->Size = sizeof(unsigned) +
(sizeof(DirectoryEntry) * node->Children[i]->Children.size());
CurrentOffset += node->Children[i]->Size;
// If it is a directory, go in
if (node->Children[i]->Flags & 0x2)
ProcessNodes(node->Children[i]);
}
}
bool NodeSort (Node* a, Node* b)
{
return (a->Offset < b->Offset);
}
void WriteFile (char* path)
{
FILE* in = fopen(path, "rb");
if (!in) throw ExcCannotOpenInput;
void* buffer = malloc(0x1000);
uint32 r = 0;
// Copy in 4kb blocks
while (r = fread(buffer, sizeof(uint8), 0x1000, in))
fwrite(buffer, sizeof(uint8), r, Out );
free(buffer);
}
void WriteDirectory (Node* node)
{
unsigned sz = node->Children.size();
// Write directory header (items count)
fwrite (&sz, 1, sizeof (unsigned), Out);
for (int i = 0; i < sz; i++)
{
// Get the info
DirectoryEntry dir;
memset (&dir, 0, sizeof(DirectoryEntry));
char* temp = InfoGetFileName(node->Children[i]->Name);
strcpy(dir.Name, temp);
dir.Flags = node->Children[i]->Flags;
dir.OwnerId = dir.GroupId = 0;
dir.Size = node->Children[i]->Size;
dir.TimeCreated = InfoGetFileCreated(node->Children[i]->Name);
dir.TimeModified = InfoGetFileModified(node->Children[i]->Name);
dir.TimeAccessed = InfoGetTime();
dir.Offset = node->Children[i]->Offset;
// Write it
fwrite (&dir, 1, sizeof(DirectoryEntry), Out);
}
}
void CommandClose ()
{
unsigned MAGIC = 0xCC23AA90;
char* OemStr = "luxram";
CurrentOffset = sizeof(MAGIC) + strlen(OemStr);
// Process root
Root.Offset = CurrentOffset;
Root.Size = sizeof (unsigned) + (Root.Children.size() * sizeof(DirectoryEntry));
CurrentOffset += Root.Size;
// Process recursively all the nodes
ProcessNodes(&Root);
// Now we need to sort the nodes by offset
sort(list.begin(), list.end(), NodeSort);
// And now we need to write everything to output file
fwrite(&MAGIC, sizeof(uint8), 4, Out); // Magic number
fwrite(OemStr, sizeof(uint8), strlen(OemStr), Out); // Oem string
WriteDirectory(&Root); // Write the root
for (int i = 0; i < list.size(); i++)
{
// If file, write content
if (list[i]->Flags & 1) WriteFile(list[i]->Name);
// If directory, write list
else WriteDirectory(list[i]);
}
// Done; cleanup
while (list.size()) {
delete list.back();
list.pop_back();
}
fclose(Out);
}

Binary file not shown.

View File

@ -0,0 +1,70 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include "types.h"
#include "info.h"
string InfoGetFileName (string path)
{
string t = strrchr(path, '\\');
if (t == NULL) return path;
return (t + 1);
}
uint32 InfoGetFileSize (string path)
{
FILE* f = fopen (path, "r");
if (!f) return 0;
fseek(f, 0, SEEK_END);
uint32 ret = (uint32) ftell(f);
fclose (f);
return ret;
}
TimeSystem ConvertTimeToTimeSystem (struct tm t)
{
TimeSystem sys = {0,0};
uint32 year = 1900 + t.tm_year - 1;
uint32 yday = t.tm_yday;
sys.Time = (t.tm_hour * 3600000) + (uint32)(t.tm_min * 60000) + (uint32)(t.tm_sec * 1000);
sys.Date = (yday) + (uint32)((year/4) * (365*4 + 1)) + (uint32)(year%4 * 365);
return sys;
}
TimeSystem InfoGetTime ()
{
time_t now = time(NULL);
struct tm* t = gmtime(&now);
return ConvertTimeToTimeSystem(*t);
}
TimeSystem InfoGetFileCreated(string file)
{
struct tm* time;
struct stat attrib;
stat(file, &attrib);
time = gmtime(&(attrib.st_ctime));
if (time == NULL) return InfoGetTime();
return ConvertTimeToTimeSystem(*time);
}
TimeSystem InfoGetFileModified(string file)
{
struct tm* time;
struct stat attrib;
stat(file, &attrib);
time = gmtime(&(attrib.st_mtime));
if (time == NULL) return InfoGetTime();
return ConvertTimeToTimeSystem(*time);
}

View File

@ -0,0 +1,20 @@
/*
* File: info.h
* Author: Tiberiu
*
* Created on August 31, 2011, 3:15 PM
*/
#ifndef INFO_H
#define INFO_H
#include "types.h"
extern string InfoGetFileName (string path);
extern uint32 InfoGetFileSize (string path);
extern TimeSystem InfoGetTime ();
extern TimeSystem InfoGetFileCreated(string file);
extern TimeSystem InfoGetFileModified(string file);
#endif /* INFO_H */

View File

@ -0,0 +1,14 @@
CREATE "filename" ; creates a new ramdisk with the filename
MKDIR "name" ; creates a new directory (in current dir)
CD "\path" ; sets current directory
ADD "filename" ; adds a file to current directory!
SETFLAGS 1A1B01 ; sets flags for next added files, number is in hex using this mask:
* bits description
* 0-2 file type; ignored, autocompleted at writing
* 3-5 owner permissions (rwx); w ignored (read only device)
* 6-8 group permissions (rwx); w ignored
* 9-11 other permissions (rwx); w ignored
* 12 hidden
; default mask is: B68 (no write, everyone can execute and read)
#asdf ; comment
CLOSE ; writes and closes the ramdisk. You must close before opening another one

View File

@ -0,0 +1,131 @@
/*
* File: main.cpp
* Author: Tiberiu
*
* Created on August 31, 2011, 2:54 PM
*/
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "types.h"
using namespace std;
extern void CommandCreate (char** argv, int argc);
extern void CommandSetFlags (char** argv, int argc);
extern void CommandAddFile (char** argv, int argc);
extern void CommandAddDirectory (char** argv, int argc);
extern void CommandChangeDirectory (char** argv, int argc);
extern void CommandClose ();
void GetParams(char* buffer, char* params[], int &count)
{
bool inside_quotes = false;
int len = strlen(buffer);
count = 0;
if (buffer[0] == '#')
{
count = 1; params[0] = ""; return;
}
if (!isspace(buffer[0])) params[count++] = buffer;
else buffer[0] = 0;
for (int i = 1; i < len && count < 16; i++)
{
if (buffer[i] == '"') {
inside_quotes = (inside_quotes) ? false : true;
if (inside_quotes && buffer[i-1] == 0) params[count++] = &buffer[i];
++i;
}
if (inside_quotes) continue;
// Comment
if (buffer[i] == '#') {
buffer[i] = 0;
break;
}
if (!isspace(buffer[i]) && (buffer[i-1]==0))
params[count++] = &buffer[i];
else if (isspace(buffer[i])) buffer[i] = 0;
}
if (count == 0) {
count = 1;
params[0] = "";
}
}
bool LineEmpty (char* s)
{
for (int i = 0; i < strlen(s); i++)
if (!isspace(s[i])) return false;
}
void ExecuteScript (char* input)
{
char buffer[1024];
char* argv[16]; int argc;
// Try to open file
FILE* in = fopen(input, "r");
if (!in) { perror(input); return ; }
// Read file line by line
printf("Reading script file %s...\n", input);
for (int line = 0; fgets(buffer, 1024, in); line++)
{
GetParams(buffer, argv, argc);
try {
if (strcmp(argv[0], "CREATE") == 0) CommandCreate(argv, argc);
else if (strcmp(argv[0], "CLOSE") == 0) CommandClose();
else if (strcmp(argv[0], "MKDIR") == 0) CommandAddDirectory(argv, argc);
else if (strcmp(argv[0], "CD") == 0) CommandChangeDirectory(argv, argc);
else if (strcmp(argv[0], "ADD") == 0) CommandAddFile(argv, argc);
else if (strcmp(argv[0], "SETFLAGS") == 0) CommandSetFlags(argv, argc);
else if (LineEmpty(argv[0])) continue;
else {
fprintf(stderr, "%i: Invalid command.\n", line);
exit(1);
}
}
catch (int exc) {
// Exception handler
switch (exc) {
case ExcCannotOpenInput: fprintf(stderr, "%i: Cannot open input file.\n", line); break;
case ExcCannotOpenOutput: fprintf(stderr, "%i: Cannot open output file.\n", line); break;
case ExcInvalidCommand: fprintf(stderr, "%i: Invalid command.\n", line); break;
case ExcInvalidPath: fprintf(stderr, "%i: Invalid path.\n", line); break;
case ExcSyntaxError: fprintf(stderr, "%i: Syntax error, robably missing parameter.\n", line); break;
}
printf("An error occurred, execution has been terminated.\n");
exit(1);
}
memset(buffer, 0, 1024 * sizeof(char));
}
fclose (in);
}
int main(int argc, char** argv) {
if (argc < 2) {
fprintf(stderr, "Missing parameter: script file.");
return 1;
}
for (int i = 1; i < argc; i++)
ExecuteScript (argv[i]);
return 0;
}

Binary file not shown.

View File

@ -0,0 +1,94 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc.exe
CCC=g++.exe
CXX=g++.exe
FC=
AS=as.exe
# Macros
CND_PLATFORM=MinGW-Windows
CND_CONF=Debug
CND_DISTDIR=dist
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/main.o \
${OBJECTDIR}/commands.o \
${OBJECTDIR}/info.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/ramdiskwriter.exe
dist/Debug/MinGW-Windows/ramdiskwriter.exe: ${OBJECTFILES}
${MKDIR} -p dist/Debug/MinGW-Windows
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
${OBJECTDIR}/commands.o: commands.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/commands.o commands.cpp
${OBJECTDIR}/info.o: info.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -g -MMD -MP -MF $@.d -o ${OBJECTDIR}/info.o info.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r build/Debug
${RM} dist/Debug/MinGW-Windows/ramdiskwriter.exe
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc

View File

@ -0,0 +1,94 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a -pre and a -post target defined where you can add customized code.
#
# This makefile implements configuration specific macros and targets.
# Environment
MKDIR=mkdir
CP=cp
GREP=grep
NM=nm
CCADMIN=CCadmin
RANLIB=ranlib
CC=gcc.exe
CCC=g++.exe
CXX=g++.exe
FC=
AS=as.exe
# Macros
CND_PLATFORM=MinGW-Windows
CND_CONF=Release
CND_DISTDIR=dist
# Include project Makefile
include Makefile
# Object Directory
OBJECTDIR=build/${CND_CONF}/${CND_PLATFORM}
# Object Files
OBJECTFILES= \
${OBJECTDIR}/main.o \
${OBJECTDIR}/commands.o \
${OBJECTDIR}/info.o
# C Compiler Flags
CFLAGS=
# CC Compiler Flags
CCFLAGS=
CXXFLAGS=
# Fortran Compiler Flags
FFLAGS=
# Assembler Flags
ASFLAGS=
# Link Libraries and Options
LDLIBSOPTIONS=
# Build Targets
.build-conf: ${BUILD_SUBPROJECTS}
"${MAKE}" -f nbproject/Makefile-Release.mk dist/Release/MinGW-Windows/ramdiskwriter.exe
dist/Release/MinGW-Windows/ramdiskwriter.exe: ${OBJECTFILES}
${MKDIR} -p dist/Release/MinGW-Windows
${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter ${OBJECTFILES} ${LDLIBSOPTIONS}
${OBJECTDIR}/main.o: main.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/main.o main.cpp
${OBJECTDIR}/commands.o: commands.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/commands.o commands.cpp
${OBJECTDIR}/info.o: info.cpp
${MKDIR} -p ${OBJECTDIR}
${RM} $@.d
$(COMPILE.cc) -O2 -MMD -MP -MF $@.d -o ${OBJECTDIR}/info.o info.cpp
# Subprojects
.build-subprojects:
# Clean Targets
.clean-conf: ${CLEAN_SUBPROJECTS}
${RM} -r build/Release
${RM} dist/Release/MinGW-Windows/ramdiskwriter.exe
# Subprojects
.clean-subprojects:
# Enable dependency checking
.dep.inc: .depcheck-impl
include .dep.inc

View File

@ -0,0 +1,133 @@
#
# Generated Makefile - do not edit!
#
# Edit the Makefile in the project folder instead (../Makefile). Each target
# has a pre- and a post- target defined where you can add customization code.
#
# This makefile implements macros and targets common to all configurations.
#
# NOCDDL
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
# and .clean-reqprojects-conf unless SUB has the value 'no'
SUB_no=NO
SUBPROJECTS=${SUB_${SUB}}
BUILD_SUBPROJECTS_=.build-subprojects
BUILD_SUBPROJECTS_NO=
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
CLEAN_SUBPROJECTS_=.clean-subprojects
CLEAN_SUBPROJECTS_NO=
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
# Project Name
PROJECTNAME=RamdiskWriter
# Active Configuration
DEFAULTCONF=Debug
CONF=${DEFAULTCONF}
# All Configurations
ALLCONFS=Debug Release
# build
.build-impl: .build-pre .validate-impl .depcheck-impl
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf
# clean
.clean-impl: .clean-pre .validate-impl .depcheck-impl
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf
# clobber
.clobber-impl: .clobber-pre .depcheck-impl
@#echo "=> Running $@..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .clean-conf; \
done
# all
.all-impl: .all-pre .depcheck-impl
@#echo "=> Running $@..."
for CONF in ${ALLCONFS}; \
do \
"${MAKE}" -f nbproject/Makefile-$${CONF}.mk QMAKE=${QMAKE} SUBPROJECTS=${SUBPROJECTS} .build-conf; \
done
# build tests
.build-tests-impl: .build-impl .build-tests-pre
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-tests-conf
# run tests
.test-impl: .build-tests-impl .test-pre
@#echo "=> Running $@... Configuration=$(CONF)"
"${MAKE}" -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .test-conf
# dependency checking support
.depcheck-impl:
@echo "# This code depends on make tool being used" >.dep.inc
@if [ -n "${MAKE_VERSION}" ]; then \
echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
echo "include \$${DEPFILES}" >>.dep.inc; \
echo "endif" >>.dep.inc; \
else \
echo ".KEEP_STATE:" >>.dep.inc; \
echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
fi
# configuration validation
.validate-impl:
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
echo ""; \
echo "Error: can not find the makefile for configuration '${CONF}' in project ${PROJECTNAME}"; \
echo "See 'make help' for details."; \
echo "Current directory: " `pwd`; \
echo ""; \
fi
@if [ ! -f nbproject/Makefile-${CONF}.mk ]; \
then \
exit 1; \
fi
# help
.help-impl: .help-pre
@echo "This makefile supports the following configurations:"
@echo " ${ALLCONFS}"
@echo ""
@echo "and the following targets:"
@echo " build (default target)"
@echo " clean"
@echo " clobber"
@echo " all"
@echo " help"
@echo ""
@echo "Makefile Usage:"
@echo " make [CONF=<CONFIGURATION>] [SUB=no] build"
@echo " make [CONF=<CONFIGURATION>] [SUB=no] clean"
@echo " make [SUB=no] clobber"
@echo " make [SUB=no] all"
@echo " make help"
@echo ""
@echo "Target 'build' will build a specific configuration and, unless 'SUB=no',"
@echo " also build subprojects."
@echo "Target 'clean' will clean a specific configuration and, unless 'SUB=no',"
@echo " also clean subprojects."
@echo "Target 'clobber' will remove all built files from all configurations and,"
@echo " unless 'SUB=no', also from subprojects."
@echo "Target 'all' will will build all configurations and, unless 'SUB=no',"
@echo " also build subprojects."
@echo "Target 'help' prints this message."
@echo ""

View File

@ -0,0 +1,24 @@
#
# Generated - do not edit!
#
# NOCDDL
#
CND_BASEDIR=`pwd`
CND_BUILDDIR=build
CND_DISTDIR=dist
# Debug configuration
CND_PLATFORM_Debug=MinGW-Windows
CND_ARTIFACT_DIR_Debug=dist/Debug/MinGW-Windows
CND_ARTIFACT_NAME_Debug=ramdiskwriter
CND_ARTIFACT_PATH_Debug=dist/Debug/MinGW-Windows/ramdiskwriter
CND_PACKAGE_DIR_Debug=dist/Debug/MinGW-Windows/package
CND_PACKAGE_NAME_Debug=ramdiskwriter.tar
CND_PACKAGE_PATH_Debug=dist/Debug/MinGW-Windows/package/ramdiskwriter.tar
# Release configuration
CND_PLATFORM_Release=MinGW-Windows
CND_ARTIFACT_DIR_Release=dist/Release/MinGW-Windows
CND_ARTIFACT_NAME_Release=ramdiskwriter
CND_ARTIFACT_PATH_Release=dist/Release/MinGW-Windows/ramdiskwriter
CND_PACKAGE_DIR_Release=dist/Release/MinGW-Windows/package
CND_PACKAGE_NAME_Release=ramdiskwriter.tar
CND_PACKAGE_PATH_Release=dist/Release/MinGW-Windows/package/ramdiskwriter.tar

View File

@ -0,0 +1,74 @@
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_PLATFORM=MinGW-Windows
CND_CONF=Debug
CND_DISTDIR=dist
NBTMPDIR=build/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter
OUTPUT_BASENAME=ramdiskwriter
PACKAGE_TOP_DIR=ramdiskwriter/
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
rm -rf ${NBTMPDIR}
mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory "${NBTMPDIR}/ramdiskwriter/bin"
copyFileToTmpDir "${OUTPUT_PATH}.exe" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}.exe" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar
cd ${NBTMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${NBTMPDIR}

View File

@ -0,0 +1,74 @@
#!/bin/bash -x
#
# Generated - do not edit!
#
# Macros
TOP=`pwd`
CND_PLATFORM=MinGW-Windows
CND_CONF=Release
CND_DISTDIR=dist
NBTMPDIR=build/${CND_CONF}/${CND_PLATFORM}/tmp-packaging
TMPDIRNAME=tmp-packaging
OUTPUT_PATH=${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/ramdiskwriter
OUTPUT_BASENAME=ramdiskwriter
PACKAGE_TOP_DIR=ramdiskwriter/
# Functions
function checkReturnCode
{
rc=$?
if [ $rc != 0 ]
then
exit $rc
fi
}
function makeDirectory
# $1 directory path
# $2 permission (optional)
{
mkdir -p "$1"
checkReturnCode
if [ "$2" != "" ]
then
chmod $2 "$1"
checkReturnCode
fi
}
function copyFileToTmpDir
# $1 from-file path
# $2 to-file path
# $3 permission
{
cp "$1" "$2"
checkReturnCode
if [ "$3" != "" ]
then
chmod $3 "$2"
checkReturnCode
fi
}
# Setup
cd "${TOP}"
mkdir -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package
rm -rf ${NBTMPDIR}
mkdir -p ${NBTMPDIR}
# Copy files and create directories and links
cd "${TOP}"
makeDirectory "${NBTMPDIR}/ramdiskwriter/bin"
copyFileToTmpDir "${OUTPUT_PATH}.exe" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}.exe" 0755
# Generate tar file
cd "${TOP}"
rm -f ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar
cd ${NBTMPDIR}
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/package/ramdiskwriter.tar *
checkReturnCode
# Cleanup
cd "${TOP}"
rm -rf ${NBTMPDIR}

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="69">
<logicalFolder name="root" displayName="root" projectFiles="true">
<logicalFolder name="HeaderFiles"
displayName="Header Files"
projectFiles="true"
kind="SOURCE_LOGICAL_FOLDER">
</logicalFolder>
<logicalFolder name="ResourceFiles"
displayName="Resource Files"
projectFiles="true"
kind="SOURCE_LOGICAL_FOLDER">
</logicalFolder>
<logicalFolder name="SourceFiles"
displayName="Source Files"
projectFiles="true"
kind="SOURCE_LOGICAL_FOLDER">
<itemPath>commands.cpp</itemPath>
<itemPath>info.cpp</itemPath>
<itemPath>main.cpp</itemPath>
</logicalFolder>
<logicalFolder name="TestFiles"
displayName="Test Files"
projectFiles="false"
kind="TEST_LOGICAL_FOLDER">
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
projectFiles="false"
kind="IMPORTANT_FILES_FOLDER">
<itemPath>Makefile</itemPath>
</logicalFolder>
<itemPath>info.h</itemPath>
<itemPath>sample.txt</itemPath>
<itemPath>types.h</itemPath>
</logicalFolder>
<projectmakefile>Makefile</projectmakefile>
<confs>
<conf name="Debug" type="1">
<toolsSet>
<developmentServer>localhost</developmentServer>
<compilerSet>MinGW|MinGW</compilerSet>
<platform>3</platform>
</toolsSet>
<compileType>
</compileType>
</conf>
<conf name="Release" type="1">
<toolsSet>
<developmentServer>localhost</developmentServer>
<compilerSet>MinGW|MinGW</compilerSet>
<platform>3</platform>
</toolsSet>
<compileType>
<cTool>
<developmentMode>5</developmentMode>
</cTool>
<ccTool>
<developmentMode>5</developmentMode>
</ccTool>
<fortranCompilerTool>
<developmentMode>5</developmentMode>
</fortranCompilerTool>
<asmTool>
<developmentMode>5</developmentMode>
</asmTool>
</compileType>
</conf>
</confs>
</configurationDescriptor>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<configurationDescriptor version="69">
<projectmakefile>Makefile</projectmakefile>
<defaultConf>0</defaultConf>
<confs>
<conf name="Debug" type="1">
<gizmo_options version="3">
<configurationname>GizmoSimple</configurationname>
</gizmo_options>
<runprofile version="6">
<args>sample.txt</args>
<rundir></rundir>
<buildfirst>true</buildfirst>
<console-type>0</console-type>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
<conf name="Release" type="1">
<gizmo_options version="3">
<configurationname>GizmoSimple</configurationname>
</gizmo_options>
<runprofile version="6">
<args></args>
<rundir></rundir>
<buildfirst>true</buildfirst>
<console-type>0</console-type>
<terminal-type>0</terminal-type>
<remove-instrumentation>0</remove-instrumentation>
<environment>
</environment>
</runprofile>
</conf>
</confs>
</configurationDescriptor>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
</project-private>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.cnd.makeproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/make-project/1">
<name>RamdiskWriter</name>
<make-project-type>0</make-project-type>
<c-extensions/>
<cpp-extensions>cpp</cpp-extensions>
<header-extensions>h</header-extensions>
<sourceEncoding>UTF-8</sourceEncoding>
<make-dep-projects/>
<sourceRootList/>
<confList>
<confElem>Debug</confElem>
<confElem>Release</confElem>
</confList>
</data>
</configuration>
</project>

View File

@ -0,0 +1,16 @@
# This is a sample script
CREATE "myram.sys"
ADD "info.h"
ADD "types.h"
# We go inside the sources folder
MKDIR "sources"
CD "sources"
ADD "commands.cpp"
ADD "info.cpp"
SETFLAGS B68 # Change flags mask; B68 is the default mask.
ADD "main.cpp"
CD ".."
CLOSE

View File

@ -0,0 +1,41 @@
/*
* File: types.h
* Author: Tiberiu
*
* Created on August 31, 2011, 2:58 PM
*/
#ifndef TYPES_H
#define TYPES_H
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
typedef signed int int32;
typedef signed short int16;
typedef signed char int8;
typedef char* string;
typedef struct {
uint32 Date, Time;
} TimeSystem;
typedef struct {
char Name[256];
unsigned Flags, OwnerId, GroupId, Size;
TimeSystem TimeCreated, TimeModified, TimeAccessed;
unsigned Offset;
} __attribute__((packed)) DirectoryEntry;
enum Exceptions {
ExcSyntaxError,
ExcCannotOpenOutput,
ExcInvalidPath,
ExcCannotOpenInput,
ExcInvalidCommand
};
#endif /* TYPES_H */