![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
static API |
karistouf
Member #5,126
October 2004
![]() |
hello everybody... I have still a question that should be easy to answer for a lot of you ... ;-P My app is static in its way of work ( working with dll , alllegro and windows. I didn t figure out how to know wich is the hard disk ( "C:" )and the folder (\\somewhere\\my_app_name) if I let users install it anywhere on their computer. Could someone explain me wich syntax to use to have the resident directory of installation? And how to navigate inside of it ? I would like for example to let users use my app from an usb-key. This app is under windows, but cant be worked from emultaor under linux because of this particuliar point. Thanks for answer! "step by step" |
gnolam
Member #2,030
March 2002
![]() |
guillermet christoph said: My app is static in its way of work
You keep using that word. I do not think it means what you think it means. guillermet christoph said: Could someone explain me wich syntax to use to have the resident directory of installation? Just using a relative path works in itself (no chdirs are required), if the user starts the program by double-clicking the executable: load_bitmap("foo.bmp", NULL); //load "foo.bmp" in the same directory as the exe load_bitmap("bar/foo.bmp", NULL); //load "foo.bmp" in the subdirectory "bar" (I'm using forward slashes here as they work in both Windows and UNIX) But to be completely sure, you can combine get_executable_name(char *buf, int size); E.g.: char path[512]; get_executable_name(path, sizeof(path)); replace_filename(path, path, "foo.bmp", sizeof(path)); load_bitmap(path, NULL);
[EDIT] -- |
ixilom
Member #7,167
April 2006
![]() |
I believe the last row of code in gnolam's post should be load_bitmap(path,NULL);
Maybe that was obvious to the OP though ___________________________________________ |
karistouf
Member #5,126
October 2004
![]() |
ok... interresting... on static definition: for me Blender ( on linux and win) is a static api: it has all the dll and drivers it needs to work. A program that need external library installed on the system is not static. But perhaps Im wrong ? get_executable_name is good, is there any split function to navigate easely from folder up to folder down ? my app is there : /MY_APP_FOLDER/BIN/my_app.exe so i need to navigate easely... thanks !!! "step by step" |
ixilom
Member #7,167
April 2006
![]() |
Static to me is something that doesn't change, the opposite of dynamic. As for getting different directory "levels", there is no such magic function AFAIK. ___________________________________________ |
karistouf
Member #5,126
October 2004
![]() |
i hate string management .... nostring minded am I...;D is there any function in mingw that do a replacement in a string of a certain keyword ( replace /bin by /saves ) ? but thanks... really! "step by step" |
Kibiz0r
Member #6,203
September 2005
![]() |
Sorry to post for no apparent reason, but... Quote:
You keep using that word. I do not think it means what you think it means. I laughed. A lot. --- |
karistouf
Member #5,126
October 2004
![]() |
we agree that static is the good term when you do not install libraries on the system to run your app?????????????????????????? "step by step" |
ixilom
Member #7,167
April 2006
![]() |
I believe they mean static as in the libraries were built into the executable itself, not requiring any external libraries. The normal way of running Linux applications is to require the user to install the libraries that are needed, sharing the libraries with a bunch of other software. ___________________________________________ |
tobing
Member #5,213
November 2004
![]() |
Quote: we agree that static is the good term when you do not install libraries on the system to run your app No. Static is the opposite of dynamic, and refers to how you use libraries. So I guess you think of applications that are statically linked, so there are no runtime dependencies to other libraries which may have to be installed as well. This would not be called 'static' however, but stand-alone or independent, or self-contained or whatever. Edit: I also don't get why you use the term API. It's the shorthand for Application Programming Interface, and doesn't make sense the way you're using it... |
Paul whoknows
Member #5,081
September 2004
![]() |
The way you compile your program does not affect its path. ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
karistouf
Member #5,126
October 2004
![]() |
ok lets stay statically linked. "step by step" |
LennyLen
Member #5,313
December 2004
![]() |
Quote: is there any function in mingw that do a replacement in a string of a certain keyword ( replace /bin by /saves ) ? No, there isn't*. But you can use strstr() to find the first occurance of the substring you want to replace, then copy all of the proceeding string to a buffer, then strcat() what you want to replace it with, then copy the rest of the original string to the buffer. * Not in C anyway. I don't know about C++. edit: Quote: ok lets stay statically linked. If you're using the Allegro dll, which I assume you are, since you mentined dlls in your original post, then you are dynamically linking, not statically linking (dll == Dynamic Link Library).
|
CGamesPlay
Member #2,559
July 2002
![]() |
replace_filenamereplace_filename will change /bin to /saves, assuming the last component of the path name is /bin. -- Ryan Patterson - <http://cgamesplay.com/> |
LennyLen
Member #5,313
December 2004
![]() |
Quote: replace_filename will change /bin to /saves, assuming the last component of the path name is /bin.
That's not a MinGW (GCC) function though.
|
CGamesPlay
Member #2,559
July 2002
![]() |
Sure, but this is obviously an Allegro question. See the second post in the thread -- Ryan Patterson - <http://cgamesplay.com/> |
LennyLen
Member #5,313
December 2004
![]() |
Quote: See the second post in the thread Nah, I'm busy looking at this part now: Quote: get_executable_name is good, is there any split function to navigate easely from folder up to folder down ? my app is there : /MY_APP_FOLDER/BIN/my_app.exe In DOS/Windows, ".." represents the parent directory, does this hold true for other OSes?
|
CGamesPlay
Member #2,559
July 2002
![]() |
Yeah, it does. But you can't do MY_APP_FOLDER/BIN/my_app.exe/../../IMAGES, you have to get the directory name twice, then append the IMAGES part. I suppose you could get away with getting the directory name without a trailing slash and then calling replace_filename. -- Ryan Patterson - <http://cgamesplay.com/> |
karistouf
Member #5,126
October 2004
![]() |
strstr used and used with strncat. "step by step" |
BAF
Member #2,981
December 2002
![]() |
Use / not \\. / will work on all platforms, plus you don't have to escape it. It also looks better because you don't have toe scape it. |
karistouf
Member #5,126
October 2004
![]() |
sorry but / is not working on my dev cpp + mingw32. Its like this... But on the ".." I can say that simplest solutions are the best. It works now, I just have to adapt some few things.... thank you "step by step" |
LennyLen
Member #5,313
December 2004
![]() |
Quote: sorry but / is not working on my dev cpp + mingw32. Its like this... How did you use it? It should work fine. eg: output = fopen("../output.txt", "w");
|
karistouf
Member #5,126
October 2004
![]() |
chdir ("..") what a pity that in mingw32 the main interresting function in libc are missing... "step by step" |
LennyLen
Member #5,313
December 2004
![]() |
Quote:
chdir ("..") The following code worked perfectly for me with MinGW:
Quote: what a pity that in mingw32 the main interresting function in libc are missing... Such as?
|
Jonatan Hedborg
Member #4,886
July 2004
![]() |
'/' works perfectly in Mingw32. There are no missing libc functions in mingw32 that I'm aware of...
|
|
1
2
|