Lots of path and file name issues resolved.
This commit is contained in:
parent
fc859dc05c
commit
1a176f2270
10 changed files with 182 additions and 49 deletions
|
@ -91,6 +91,7 @@ doBuild Singe-Windows-x86_64 mingw 64 .exe
|
|||
rm /tmp/icon.ico
|
||||
rm /tmp/icon.png
|
||||
rm /tmp/singe.res
|
||||
#cp ../build/mingw/64/Singe-Windows-x86_64.exe ../test/.
|
||||
|
||||
# 32 Bit Raspbian
|
||||
echo -e "${G_L}\nLinux armv6\n${G_L}"
|
||||
|
|
|
@ -125,7 +125,7 @@ int32_t frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Re
|
|||
// Get path where video files live
|
||||
path = utilReadLine(data, bytes, &offset);
|
||||
if (!path) utilDie("Cannot read video path from framefile!");
|
||||
utilFixPathSeparators(&path);
|
||||
utilFixPathSeparators(&path, true);
|
||||
|
||||
// If it's not an absolute path, pre-pend the path to the framefile
|
||||
if ((path[0] != utilGetPathSeparator()) && (path[1] != ':')) {
|
||||
|
@ -136,7 +136,7 @@ int32_t frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Re
|
|||
memcpy(&path[count], temp, strlen(temp));
|
||||
path[count + strlen(temp)] = 0;
|
||||
free(temp);
|
||||
utilFixPathSeparators(&path);
|
||||
utilFixPathSeparators(&path, true);
|
||||
count = 0;
|
||||
}
|
||||
|
||||
|
|
BIN
singe/indexing.xcf
(Stored with Git LFS)
BIN
singe/indexing.xcf
(Stored with Git LFS)
Binary file not shown.
BIN
singe/magnifyingGlass.xcf
(Stored with Git LFS)
BIN
singe/magnifyingGlass.xcf
(Stored with Git LFS)
Binary file not shown.
11
singe/main.c
11
singe/main.c
|
@ -326,6 +326,7 @@ int main(int argc, char *argv[]) {
|
|||
// Did we get a filename or path to open?
|
||||
if ((argc - argCount) != 1) showUsage(exeName, "No script file specified.");
|
||||
_confScriptFile = strdup(argv[argCount]);
|
||||
utilFixPathSeparators(&_confScriptFile, false);
|
||||
// Exists?
|
||||
if (!utilFileExists(_confScriptFile)) {
|
||||
// Missing. Is a path?
|
||||
|
@ -352,6 +353,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Do we need to generate a video name?
|
||||
if (_confVideoFile) {
|
||||
utilFixPathSeparators(&_confVideoFile, false);
|
||||
if (!utilFileExists(_confVideoFile)) {
|
||||
free(_confVideoFile);
|
||||
_confVideoFile = NULL;
|
||||
|
@ -392,6 +394,10 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
// Do we need to generate a data directory name?
|
||||
if (_confDataDir) {
|
||||
utilFixPathSeparators(&_confDataDir, false);
|
||||
// Try to create data directory to ensure it exists.
|
||||
utilMkDirP(_confDataDir, 0777);
|
||||
// Does it exist?
|
||||
if (!utilPathExists(_confDataDir)) {
|
||||
free(_confDataDir);
|
||||
_confDataDir = NULL;
|
||||
|
@ -402,9 +408,6 @@ int main(int argc, char *argv[]) {
|
|||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
// All this temp nonsense here...
|
||||
// I had just jammed a zero into _confDataDir at 'x' but then if utilFixPathSeparators
|
||||
// calls realloc() it pooches things up. Weird.
|
||||
temp = strdup(_confScriptFile);
|
||||
temp[x] = 0;
|
||||
_confDataDir = strdup(temp);
|
||||
|
@ -412,7 +415,7 @@ int main(int argc, char *argv[]) {
|
|||
temp = NULL;
|
||||
}
|
||||
if (!_confDataDir) showUsage(exeName, "Unable to locate data directory.");
|
||||
utilFixPathSeparators(&_confDataDir);
|
||||
utilFixPathSeparators(&_confDataDir, true);
|
||||
|
||||
// Do they want tracing?
|
||||
if (tracing) {
|
||||
|
|
|
@ -1927,6 +1927,7 @@ void doIndexDisplay(int32_t percent) {
|
|||
}
|
||||
|
||||
// Display animation
|
||||
SDL_RenderSetLogicalSize(_renderer, screenW, screenH);
|
||||
SDL_SetRenderDrawColor(_renderer, 0, 0, 0, 255);
|
||||
SDL_RenderClear(_renderer);
|
||||
|
||||
|
@ -1954,8 +1955,9 @@ void doIndexDisplay(int32_t percent) {
|
|||
|
||||
// Update animation
|
||||
if (SDL_GetTicks() > nextUpdate) {
|
||||
//angle += (SDL_GetTicks() - nextUpdate) / updateTicks;
|
||||
angle++;
|
||||
if (angle > 359) angle = 0;
|
||||
if (angle > 359) angle -= 360;
|
||||
nextUpdate = SDL_GetTicks() + updateTicks;
|
||||
}
|
||||
|
||||
|
@ -2390,6 +2392,8 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
|
|||
|
||||
// Mouse setup
|
||||
_mouseCount = ManyMouse_Init();
|
||||
//utilSay("***DEBUG*** Mouse Driver: %s", ManyMouse_DriverName());
|
||||
//utilSay("***DEBUG*** Mice Found: %d", _mouseCount);
|
||||
if (_mouseCount < 1) utilDie("No mice detected.");
|
||||
if (_mouseCount > MAX_MICE) {
|
||||
_mouseCount = MAX_MICE;
|
||||
|
@ -2401,6 +2405,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
|
|||
_mice[x].name[sizeof(_mice[x].name) - 1] = 0;
|
||||
_mice[x].x = (int32_t)(videoGetWidth(_videoHandle) * _overlayScaleX);
|
||||
_mice[x].y = (int32_t)(videoGetHeight(_videoHandle) * _overlayScaleY);
|
||||
//utilSay("***DEBUG*** Mouse %d: %s", x, _mice[x].name);
|
||||
}
|
||||
SDL_SetWindowGrab(_window, SDL_TRUE);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
|
|
@ -55,17 +55,23 @@ platformPi:PLATFORM="pi"
|
|||
|
||||
static {
|
||||
BUILDTHIRDARGS = \"$$PWD/thirdparty\" \"$$OUT_PWD/../thirdparty-build\" $$BITNESS $$PLATFORM $$LIBTYPE
|
||||
win32 {
|
||||
# Placeholder - doesn't work
|
||||
BUILDTHIRD.commands = cmd.exe /c $$PWD\\preBuild.bat $$BUILDTHIRDARGS
|
||||
} else {
|
||||
|
||||
platformLinux {
|
||||
BUILDTHIRD.commands = bash $$PWD/preBuild.sh $$BUILDTHIRDARGS
|
||||
}
|
||||
BUILDTHIRD.target = this
|
||||
PRE_TARGETDEPS += this
|
||||
QMAKE_EXTRA_TARGETS += BUILDTHIRD
|
||||
}
|
||||
|
||||
platformPi {
|
||||
message("No Pi support for building prereqs - yet.")
|
||||
}
|
||||
|
||||
platformMingw {
|
||||
message("No Windows support for building prereqs - yet.")
|
||||
}
|
||||
}
|
||||
|
||||
# === Arg_Parser ===
|
||||
|
||||
ARGPARSER_INCLUDES = \
|
||||
|
@ -101,9 +107,17 @@ QMAKE_CFLAGS += \
|
|||
-isystem $$PWD/../thirdparty-build/$$PLATFORM/$$BITNESS/installed/include
|
||||
|
||||
dynamic {
|
||||
platformLinux {
|
||||
message("No Linux support for building dynamically.")
|
||||
}
|
||||
|
||||
platformPi {
|
||||
QMAKE_CFLAGS += -I/usr/include/lua5.3
|
||||
}
|
||||
|
||||
platformMingw {
|
||||
message("No Windows support for building dynamically.")
|
||||
}
|
||||
}
|
||||
|
||||
HEADERS += \
|
||||
|
@ -136,16 +150,46 @@ SOURCES += \
|
|||
LIBS += \
|
||||
-L$$PWD/../thirdparty-build/$$PLATFORM/$$BITNESS/installed/lib \
|
||||
-lpthread \
|
||||
-lXv \
|
||||
-lX11 \
|
||||
-lXext \
|
||||
-lm \
|
||||
-ldl \
|
||||
-lrt
|
||||
-lm
|
||||
|
||||
static {
|
||||
LIBS += \
|
||||
-l:everything.a
|
||||
|
||||
platformLinux {
|
||||
LIBS += \
|
||||
-lXv \
|
||||
-lX11 \
|
||||
-lXext \
|
||||
-ldl \
|
||||
-lrt
|
||||
}
|
||||
|
||||
platformPi {
|
||||
message("No direct Pi support yet.")
|
||||
}
|
||||
|
||||
platformMingw {
|
||||
LIBS += \
|
||||
-mwindows \
|
||||
-static \
|
||||
-lmingw32 \
|
||||
-lbcrypt \
|
||||
-ldinput8 \
|
||||
-ldxguid \
|
||||
-ldxerr8 \
|
||||
-luser32 \
|
||||
-lgdi32 \
|
||||
-lwinmm \
|
||||
-limm32 \
|
||||
-lole32 \
|
||||
-loleaut32 \
|
||||
-lshell32 \
|
||||
-lsetupapi \
|
||||
-lversion \
|
||||
-luuid \
|
||||
-Dmain=SDL_main
|
||||
}
|
||||
}
|
||||
|
||||
dynamic {
|
||||
|
@ -189,8 +233,8 @@ OTHER_FILES += \
|
|||
buildRelease.sh \
|
||||
singe.rc
|
||||
|
||||
|
||||
#linux:QMAKE_POST_LINK += bash $$PWD/postLink.sh "$$PWD" "$$DESTDIR" "$$TARGET"
|
||||
platformLinux {
|
||||
#QMAKE_POST_LINK += bash $$PWD/postLink.sh "$$PWD" "$$DESTDIR" "$$TARGET"
|
||||
|
||||
# === Generate some data for our buildRelease script ===
|
||||
|
||||
|
@ -201,3 +245,4 @@ FILEINFO = "SOURCES=\"$$SOURCES\"" \
|
|||
"QMAKE_CFLAGS=\"$$QMAKE_CFLAGS\""
|
||||
|
||||
write_file("source.inc.sh", FILEINFO)
|
||||
}
|
||||
|
|
95
singe/util.c
95
singe/util.c
|
@ -26,7 +26,11 @@
|
|||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
#define ourMkdir(p,m) mkdir(p)
|
||||
|
||||
static const int CONSOLE_LINES = 1000;
|
||||
#else
|
||||
#define ourMkdir mkdir
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -101,29 +105,37 @@ bool utilFileExists(char *filename) {
|
|||
}
|
||||
|
||||
|
||||
void utilFixPathSeparators(char **path) {
|
||||
void utilFixPathSeparators(char **path, bool slash) {
|
||||
|
||||
int32_t i = 0;
|
||||
char *temp = *path;
|
||||
char *work = *path;
|
||||
char *temp = NULL;
|
||||
|
||||
// Flip path separators to whatever our OS wants
|
||||
while (temp[i] != 0) {
|
||||
if (temp[i] == '\\' || temp[i] == '/') {
|
||||
temp[i] = utilGetPathSeparator();
|
||||
while (work[i] != 0) {
|
||||
if (work[i] == '\\' || work[i] == '/') {
|
||||
work[i] = utilGetPathSeparator();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (slash) {
|
||||
// Does this string end with a path separator?
|
||||
if (temp[strlen(temp) - 1] != utilGetPathSeparator()) {
|
||||
if (work[strlen(work) - 1] != utilGetPathSeparator()) {
|
||||
// No - append one.
|
||||
temp = realloc(temp, sizeof(char) * (strlen(temp) + 1));
|
||||
temp[strlen(temp)] = utilGetPathSeparator();
|
||||
temp[strlen(temp) + 1] = 0;
|
||||
*path = temp;
|
||||
temp = strdup(work);
|
||||
free(work);
|
||||
work = malloc(sizeof(char) * (strlen(temp) + 1));
|
||||
strcpy(work, temp);
|
||||
work[strlen(temp)] = utilGetPathSeparator();
|
||||
work[strlen(temp) + 1] = 0;
|
||||
free(temp);
|
||||
}
|
||||
}
|
||||
|
||||
*path = work;
|
||||
}
|
||||
|
||||
|
||||
char *utilGetFileExtension(char *filename) {
|
||||
char *start = filename + strlen(filename);
|
||||
|
@ -168,6 +180,67 @@ char utilGetPathSeparator(void) {
|
|||
}
|
||||
|
||||
|
||||
bool utilMkDirP(const char *dir, const mode_t mode) {
|
||||
char tmp[UTIL_PATH_MAX];
|
||||
char *p = NULL;
|
||||
struct stat sb;
|
||||
size_t len;
|
||||
|
||||
// Make copy of dir.
|
||||
len = strnlen(dir, UTIL_PATH_MAX);
|
||||
if (len == 0 || len == UTIL_PATH_MAX) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(tmp, dir, len);
|
||||
tmp[len] = '\0';
|
||||
|
||||
// Remove trailing slash.
|
||||
if (tmp[len - 1] == utilGetPathSeparator()) {
|
||||
tmp[len - 1] = '\0';
|
||||
}
|
||||
|
||||
// Does it already exist?
|
||||
if (stat(tmp, &sb) == 0) {
|
||||
if (S_ISDIR (sb.st_mode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Recursive mkdir.
|
||||
for (p = tmp + 1; *p; p++) {
|
||||
if (*p == utilGetPathSeparator()) {
|
||||
*p = 0;
|
||||
if (stat(tmp, &sb) != 0) {
|
||||
// Does not exist - create it.
|
||||
if (ourMkdir(tmp, mode) < 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!S_ISDIR(sb.st_mode)) {
|
||||
// Not a directory
|
||||
return false;
|
||||
}
|
||||
}
|
||||
*p = utilGetPathSeparator();
|
||||
}
|
||||
}
|
||||
// Check path
|
||||
if (stat(tmp, &sb) != 0) {
|
||||
// Does not exist - create it.
|
||||
if (ourMkdir(tmp, mode) < 0) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!S_ISDIR(sb.st_mode)) {
|
||||
// Not a directory
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool utilPathExists(char *pathname) {
|
||||
DIR *dir = opendir(pathname);
|
||||
if (dir) {
|
||||
|
@ -183,6 +256,8 @@ char *utilReadFile(char *filename, size_t *bytes) {
|
|||
FILE *in = fopen(filename, "rb");
|
||||
size_t read = 0;
|
||||
|
||||
(void)read;
|
||||
|
||||
*bytes = 0;
|
||||
|
||||
if (in) {
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#define UTIL_PATH_MAX 1024
|
||||
|
||||
|
||||
extern FILE *utilTraceFile;
|
||||
|
||||
|
||||
|
@ -38,10 +42,11 @@ char *utilCreateString(char *format, ...);
|
|||
char *utilCreateStringVArgs(char *format, va_list args);
|
||||
void utilDie(char *fmt, ...);
|
||||
bool utilFileExists(char *filename);
|
||||
void utilFixPathSeparators(char **path);
|
||||
void utilFixPathSeparators(char **path, bool slash);
|
||||
char *utilGetFileExtension(char *filename);
|
||||
char *utilGetLastPathComponent(char *pathname);
|
||||
char utilGetPathSeparator(void);
|
||||
bool utilMkDirP(const char *dir, const mode_t mode);
|
||||
bool utilPathExists(char *pathname);
|
||||
char *utilReadFile(char *filename, size_t *bytes);
|
||||
char *utilReadLine(char *haystack, size_t length, char **offset);
|
||||
|
|
|
@ -148,7 +148,6 @@ int FFMS_CC _indexCallBack(int64_t current, int64_t total, void *ICPrivate) {
|
|||
thisPercent = (int32_t)((double)current / (double)total * 100.0);
|
||||
if (thisPercent != lastPercent) {
|
||||
lastPercent = thisPercent;
|
||||
//utilSay("Indexing: %d%%", thisPercent);
|
||||
// GUI
|
||||
if (_indexingFunction) {
|
||||
_indexingFunction(thisPercent);
|
||||
|
@ -175,7 +174,6 @@ FFMS_Index *_createIndex(char *filename, char *indexPath, bool hasVideo, bool ha
|
|||
}
|
||||
}
|
||||
if (!index) {
|
||||
//utilSay("Creating new index.");
|
||||
indexer = FFMS_CreateIndexer(filename, &v->errInfo);
|
||||
if (indexer == NULL) utilDie("%s", v->errInfo.Buffer);
|
||||
if (hasAudio) FFMS_TrackTypeIndexSettings(indexer, FFMS_TYPE_AUDIO, 1, 0);
|
||||
|
@ -224,7 +222,7 @@ int32_t _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bo
|
|||
// Find video track
|
||||
v->videoTrack = FFMS_GetFirstTrackOfType(vIndex, FFMS_TYPE_VIDEO, &v->errInfo);
|
||||
if (v->videoTrack < 0) utilDie("%s", v->errInfo.Buffer);
|
||||
v->videoSource = FFMS_CreateVideoSource(vFilename, v->videoTrack, vIndex, 1, FFMS_SEEK_NORMAL, &v->errInfo);
|
||||
v->videoSource = FFMS_CreateVideoSource(vFilename, v->videoTrack, vIndex, -1, FFMS_SEEK_NORMAL, &v->errInfo);
|
||||
if (v->videoSource == NULL) utilDie("%s", v->errInfo.Buffer);
|
||||
|
||||
// Get video properties
|
||||
|
@ -260,6 +258,7 @@ int32_t _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bo
|
|||
v->videoTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_BGRA32, SDL_TEXTUREACCESS_TARGET, v->propFrame->EncodedWidth, v->propFrame->EncodedHeight);
|
||||
if (v->videoTexture == NULL) utilDie("%s", SDL_GetError());
|
||||
if (!stretchVideo) {
|
||||
//***TODO*** Is this the best place for this? What if we have videos of multiple sizes?
|
||||
SDL_RenderSetLogicalSize(renderer, v->propFrame->EncodedWidth, v->propFrame->EncodedHeight);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue