forked from teamnwah/openmw-tes3coop
Properly removing the old 'misc' file and fixing a minor error in the platform CMake
This commit is contained in:
parent
819c146ad1
commit
67f89f27a2
13 changed files with 0 additions and 283 deletions
|
@ -1,8 +0,0 @@
|
||||||
#include "fileops.hpp"
|
|
||||||
#include <boost/filesystem.hpp>
|
|
||||||
|
|
||||||
bool isFile(const char *name)
|
|
||||||
{
|
|
||||||
boost::filesystem::path cfg_file_path(name);
|
|
||||||
return boost::filesystem::exists(cfg_file_path);
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
#ifndef __FILEOPS_H_
|
|
||||||
#define __FILEOPS_H_
|
|
||||||
|
|
||||||
/// Check if a given path is an existing file (not a directory)
|
|
||||||
bool isFile(const char *name);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
OpenMW - The completely unofficial reimplementation of Morrowind
|
|
||||||
Copyright (C) 2008-2010 Nicolay Korslund
|
|
||||||
Email: < korslund@gmail.com >
|
|
||||||
WWW: http://openmw.sourceforge.net/
|
|
||||||
|
|
||||||
This file (slice_array.h) is part of the OpenMW package.
|
|
||||||
|
|
||||||
OpenMW is distributed as free software: you can redistribute it
|
|
||||||
and/or modify it under the terms of the GNU General Public License
|
|
||||||
version 3, as published by the Free Software Foundation.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
version 3 along with this program. If not, see
|
|
||||||
http://www.gnu.org/licenses/ .
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SLICE_ARRAY_H_
|
|
||||||
#define _SLICE_ARRAY_H_
|
|
||||||
|
|
||||||
// A simple array implementation containing a pointer and a
|
|
||||||
// length. Used for holding slices into a data buffer.
|
|
||||||
#include <string.h>
|
|
||||||
template <class T>
|
|
||||||
struct SliceArray
|
|
||||||
{
|
|
||||||
const T* ptr;
|
|
||||||
size_t length;
|
|
||||||
|
|
||||||
/// Initialize to zero length
|
|
||||||
SliceArray() : ptr(0), length(0) {}
|
|
||||||
|
|
||||||
/// Initialize from pointer + length
|
|
||||||
SliceArray(const T* _ptr, size_t _length)
|
|
||||||
: ptr(_ptr), length(_length) {}
|
|
||||||
|
|
||||||
/// Initialize from null-terminated string
|
|
||||||
SliceArray(const char* str)
|
|
||||||
{
|
|
||||||
ptr = str;
|
|
||||||
length = strlen(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(SliceArray &t)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
length == t.length &&
|
|
||||||
(memcmp(ptr,t.ptr, length*sizeof(T)) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Only use this for stings
|
|
||||||
bool operator==(const char* str)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
str[length] == 0 &&
|
|
||||||
(strncmp(ptr, str, length) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This allocates a copy of the data. Only use this for debugging
|
|
||||||
and error messages. */
|
|
||||||
std::string toString()
|
|
||||||
{ return std::string(ptr,length); }
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SliceArray<char> SString;
|
|
||||||
typedef SliceArray<int> IntArray;
|
|
||||||
typedef SliceArray<float> FloatArray;
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,59 +0,0 @@
|
||||||
#include "stringops.hpp"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <libs/platform/strings.h>
|
|
||||||
|
|
||||||
bool begins(const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
while(*str2)
|
|
||||||
{
|
|
||||||
if(*str1 == 0 || *str1 != *str2) return false;
|
|
||||||
|
|
||||||
str1++;
|
|
||||||
str2++;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ends(const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
int len1 = strlen(str1);
|
|
||||||
int len2 = strlen(str2);
|
|
||||||
|
|
||||||
if(len1 < len2) return false;
|
|
||||||
|
|
||||||
return strcmp(str2, str1+len1-len2) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// True if the given chars match, case insensitive
|
|
||||||
static bool icmp(char a, char b)
|
|
||||||
{
|
|
||||||
if(a >= 'A' && a <= 'Z')
|
|
||||||
a += 'a' - 'A';
|
|
||||||
if(b >= 'A' && b <= 'Z')
|
|
||||||
b += 'a' - 'A';
|
|
||||||
|
|
||||||
return a == b;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ibegins(const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
while(*str2)
|
|
||||||
{
|
|
||||||
if(*str1 == 0 || !icmp(*str1,*str2)) return false;
|
|
||||||
|
|
||||||
str1++;
|
|
||||||
str2++;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool iends(const char* str1, const char* str2)
|
|
||||||
{
|
|
||||||
int len1 = strlen(str1);
|
|
||||||
int len2 = strlen(str2);
|
|
||||||
|
|
||||||
if(len1 < len2) return false;
|
|
||||||
|
|
||||||
return strcasecmp(str2, str1+len1-len2) == 0;
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
#ifndef __STRINGOPS_H
|
|
||||||
#define __STRINGOPS_H
|
|
||||||
|
|
||||||
/// Returns true if str1 begins with substring str2
|
|
||||||
bool begins(const char* str1, const char* str2);
|
|
||||||
|
|
||||||
/// Returns true if str1 ends with substring str2
|
|
||||||
bool ends(const char* str1, const char* str2);
|
|
||||||
|
|
||||||
/// Case insensitive, returns true if str1 begins with substring str2
|
|
||||||
bool ibegins(const char* str1, const char* str2);
|
|
||||||
|
|
||||||
/// Case insensitive, returns true if str1 ends with substring str2
|
|
||||||
bool iends(const char* str1, const char* str2);
|
|
||||||
|
|
||||||
#endif
|
|
1
components/misc/tests/.gitignore
vendored
1
components/misc/tests/.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
*_test
|
|
|
@ -1,12 +0,0 @@
|
||||||
GCC=g++
|
|
||||||
|
|
||||||
all: strops_test slice_test
|
|
||||||
|
|
||||||
slice_test: slice_test.cpp ../slice_array.hpp
|
|
||||||
$(GCC) $< -o $@
|
|
||||||
|
|
||||||
strops_test: strops_test.cpp ../stringops.hpp ../stringops.cpp
|
|
||||||
$(GCC) $< -o $@ ../stringops.cpp
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm *_test
|
|
|
@ -1,6 +0,0 @@
|
||||||
hello, len=5
|
|
||||||
001
|
|
||||||
hell, len=4
|
|
||||||
010
|
|
||||||
01
|
|
||||||
4 3
|
|
|
@ -1,30 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "../slice_array.hpp"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
SString s, t;
|
|
||||||
s = SString("hello");
|
|
||||||
cout << s.toString() << ", len=" << s.length << endl;
|
|
||||||
cout << (s=="hel") << (s=="hell") << (s=="hello") << endl;
|
|
||||||
t = s;
|
|
||||||
|
|
||||||
s = SString("othello"+2, 4);
|
|
||||||
cout << s.toString() << ", len=" << s.length << endl;
|
|
||||||
cout << (s=="hel") << (s=="hell") << (s=="hello") << endl;
|
|
||||||
|
|
||||||
cout << (s==t) << (SString("hello")==t) << endl;
|
|
||||||
|
|
||||||
const int arr[4] = {1,2,3,4};
|
|
||||||
|
|
||||||
IntArray ia(arr,4);
|
|
||||||
|
|
||||||
cout << ia.length << " " << ia.ptr[2] << endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "../stringops.hpp"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
assert(begins("abc", "a"));
|
|
||||||
assert(begins("abc", "ab"));
|
|
||||||
assert(begins("abc", "abc"));
|
|
||||||
assert(begins("abcd", "abc"));
|
|
||||||
|
|
||||||
assert(!begins("abc", "b"));
|
|
||||||
assert(!begins("abc", "bc"));
|
|
||||||
assert(!begins("abc", "bcd"));
|
|
||||||
assert(!begins("abc", "abcd"));
|
|
||||||
|
|
||||||
assert(ibegins("Abc", "a"));
|
|
||||||
assert(ibegins("aBc", "ab"));
|
|
||||||
assert(ibegins("abC", "abc"));
|
|
||||||
assert(ibegins("abcD", "abc"));
|
|
||||||
|
|
||||||
assert(!ibegins("abc", "b"));
|
|
||||||
assert(!ibegins("abc", "bc"));
|
|
||||||
assert(!ibegins("abc", "bcd"));
|
|
||||||
assert(!ibegins("abc", "abcd"));
|
|
||||||
|
|
||||||
assert(ends("abc", "c"));
|
|
||||||
assert(ends("abc", "bc"));
|
|
||||||
assert(ends("abc", "abc"));
|
|
||||||
assert(ends("abcd", "abcd"));
|
|
||||||
|
|
||||||
assert(!ends("abc", "b"));
|
|
||||||
assert(!ends("abc", "ab"));
|
|
||||||
assert(!ends("abc", "bcd"));
|
|
||||||
assert(!ends("abc", "abcd"));
|
|
||||||
|
|
||||||
assert(iends("Abc", "c"));
|
|
||||||
assert(iends("aBc", "bc"));
|
|
||||||
assert(iends("abC", "abc"));
|
|
||||||
assert(iends("abcD", "abcd"));
|
|
||||||
|
|
||||||
assert(!iends("abc", "b"));
|
|
||||||
assert(!iends("abc", "ab"));
|
|
||||||
assert(!iends("abc", "bcd"));
|
|
||||||
assert(!iends("abc", "abcd"));
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
make || exit
|
|
||||||
|
|
||||||
mkdir -p output
|
|
||||||
|
|
||||||
PROGS=*_test
|
|
||||||
|
|
||||||
for a in $PROGS; do
|
|
||||||
if [ -f "output/$a.out" ]; then
|
|
||||||
echo "Running $a:"
|
|
||||||
./$a | diff output/$a.out -
|
|
||||||
else
|
|
||||||
echo "Creating $a.out"
|
|
||||||
./$a > "output/$a.out"
|
|
||||||
git add "output/$a.out"
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -1,8 +1,5 @@
|
||||||
project(Platform)
|
project(Platform)
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES src/*)
|
|
||||||
file(GLOB_RECURSE CAELUM_HDR include/*)
|
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
fileops.cpp
|
fileops.cpp
|
||||||
fileops.hpp
|
fileops.hpp
|
||||||
|
|
Loading…
Reference in a new issue