aboutsummaryrefslogtreecommitdiff
path: root/KaplaDemo/samples/sampleViewer3/MediaPath.cpp
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /KaplaDemo/samples/sampleViewer3/MediaPath.cpp
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'KaplaDemo/samples/sampleViewer3/MediaPath.cpp')
-rw-r--r--KaplaDemo/samples/sampleViewer3/MediaPath.cpp285
1 files changed, 285 insertions, 0 deletions
diff --git a/KaplaDemo/samples/sampleViewer3/MediaPath.cpp b/KaplaDemo/samples/sampleViewer3/MediaPath.cpp
new file mode 100644
index 00000000..0b40e075
--- /dev/null
+++ b/KaplaDemo/samples/sampleViewer3/MediaPath.cpp
@@ -0,0 +1,285 @@
+
+
+#if defined(WIN32) || defined(WIN64)
+#define NOMINMAX
+#include <windows.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "MediaPath.h"
+
+#if defined(_XBOX)
+
+#include <xtl.h>
+#include <Xbdm.h>
+
+static bool MediaFileExists(const char *fname)
+{
+ FILE *fp=fopen(fname,"rb");
+ if(fp == NULL)
+ {
+ return false;
+ }
+ else
+ {
+ fclose(fp);
+ return true;
+ }
+}
+
+char* FindMediaFile(const char *fname,char *buff)
+{
+ strcpy(buff,"d:\\");
+ strcat(buff,fname);
+
+ if(MediaFileExists(buff))
+ return buff;
+
+ DmMapDevkitDrive();
+
+ strcpy(buff,"DEVKIT:\\");
+ strcat(buff,fname);
+
+ if(MediaFileExists(buff))
+ return buff;
+
+ char msg[1024];
+ sprintf(msg, "Can't find media file: %s\n", fname);
+ OutputDebugString(msg);
+
+ return buff;
+}
+
+char* GetTempFilePath(char *buff)
+{
+ strcpy(buff,"d:\\");
+ return buff;
+}
+
+#elif defined(__CELLOS_LV2__)
+
+#include <sys/paths.h>
+
+char* FindMediaFile(const char *fname,char *buff)
+{
+ strcpy(buff,SYS_APP_HOME "/");
+ strcat(buff,fname);
+ return buff;
+}
+
+char* GetTempFilePath(char *buff)
+{
+ strcpy(buff,SYS_APP_HOME "/");
+ return buff;
+}
+
+#elif defined(WIN32) || defined(WIN64)
+
+static bool MediaFileExists(const char *fname)
+{
+ FILE *fp=fopen(fname,"rb");
+ if(fp == NULL)
+ {
+ return false;
+ }
+ else
+ {
+ fclose(fp);
+ return true;
+ }
+}
+
+char* FindMediaFile(const char* fname, const char* path)
+{
+ static char fullPath[512];
+ strcpy(fullPath, path);
+ strcat(fullPath, "/");
+ strcat(fullPath, fname);
+ return fullPath;
+}
+
+char* FindMediaFile(const char *fname,char *buff)
+{
+ char curPath[MAX_PATH];
+ GetCurrentDirectory(MAX_PATH, curPath);
+ strcat(curPath, "\\");
+ strcpy(buff, curPath);
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ char basePath[MAX_PATH];
+ GetModuleFileName(NULL, basePath, MAX_PATH);
+ char* pTmp = strrchr(basePath, '\\');
+ if(pTmp != NULL){
+ *pTmp = 0;
+ SetCurrentDirectory(basePath);
+ pTmp = strrchr(basePath, '\\');
+ if(pTmp != NULL){
+ *pTmp = 0;
+ }
+ pTmp = strrchr(basePath, '\\');
+ if(pTmp != NULL){
+ *(pTmp + 1) = 0;
+ }
+ }
+
+ strcpy(buff, basePath);
+ strcat(buff,"..\\..\\..\\externals\\GRB\\1.0\\");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ // printf("base path is: %s\n", basePath);
+ strcpy(buff, basePath);
+ strcat(buff,"Samples\\Media\\");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff, basePath);
+ strcat(buff,"Samples\\compiler\\vc8win32\\");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff, basePath);
+ strcat(buff,"Bin\\win32\\");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ printf("Can't find media file: %s\n", fname);
+
+ strcpy(buff,fname);
+ return buff;
+}
+
+char* GetTempFilePath(char *buff)
+{
+ strcpy(buff,"");
+ return buff;
+}
+
+#elif defined(LINUX)
+
+static bool MediaFileExists(const char *fname)
+{
+ FILE *fp=fopen(fname,"rb");
+ if(fp == NULL)
+ {
+ return false;
+ }
+ else
+ {
+ fclose(fp);
+ return true;
+ }
+}
+
+char* FindMediaFile(const char *fname,char *buff)
+{
+ strcpy(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"../../Samples/Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"../../../Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"../../Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"Samples/Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ printf("Can't find media file: %s\n", fname);
+
+ strcpy(buff,fname);
+ return buff;
+}
+
+char* GetTempFilePath(char *buff)
+{
+ strcpy(buff,"");
+ return buff;
+}
+#elif defined(__PPCGEKKO__)
+
+#include <revolution/dvd.h>
+
+static bool MediaFileExists(const char *fname)
+{
+ DVDFileInfo fileInfo;
+
+ if(DVDOpen(fname,&fileInfo))
+ {
+ DVDClose(&fileInfo);
+ return true;
+ }
+
+ return false;
+
+}
+
+char* FindMediaFile(const char *fname,char *buff)
+{
+ strcpy(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"/Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"../../Samples/Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"../../../Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"../../Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ strcpy(buff,"Samples/Media/");
+ strcat(buff,fname);
+ if(MediaFileExists(buff))
+ return buff;
+
+ printf("Can't find media file: %s\n", fname);
+
+ strcpy(buff,fname);
+ return buff;
+}
+
+char* GetTempFilePath(char *buff)
+{
+ strcpy(buff,"");
+ return buff;
+}
+
+#endif