This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Re-Making FOpen?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Drak
Veteran Member
Join Date: Jul 2005
Old 08-24-2007 , 01:44   Re-Making FOpen?
Reply With Quote #1

I wanted to customize fopen, to allow me to access files other then the Mod folder. (for personal use, that is).

Well I decided just to make it a seperate module, and here's the code for the function:
Code:
static cell AMX_NATIVE_CALL amx_ffopen(AMX *amx, cell *params) {     int len;     char *file = MF_GetAmxString(amx,params[1],1,&len);     char *flags = MF_GetAmxString(amx,params[2],0,&len);         FILE *fp = fopen(file, flags);     return (cell)fp; }

Which works just fine, (The file opens/creates). But when doing "FPuts/FGets"
They fail at writing/getting data from the file. Do i have to edit the fopen in the amx core for this to work?
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 08-24-2007 , 09:05   Re: Re-Making FOpen?
Reply With Quote #2

Here is an Example how you can access higher/ another folder than the mod folder with amxx .
http://forums.alliedmods.net/showpos...55&postcount=7
__________________
schnitzelmaker is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 08-24-2007 , 09:20   Re: Re-Making FOpen?
Reply With Quote #3

Quote:
Originally Posted by schnitzelmaker View Post
Here is an Example how you can access higher/ another folder than the mod folder with amxx .
http://forums.alliedmods.net/showpos...55&postcount=7
And an tested plugin, which write an Testfile in hl directory:
Code:
#include <amxmodx> #include <amxmisc> #define PLUGIN "Upper Directory" #define VERSION "1.0" #define AUTHOR "Administrator" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     register_concmd("test","write_testfile") } public write_testfile(id){         new filename[128]     format(filename, 127, "../Test.txt")  // use "../" to get 1 directory higher.         if( !file_exists(filename) )       {         new fp = fopen(filename,"a+")         fputs(fp,"This is an Test file in an higher directory")         fclose(fp)         console_print(id,"file writed to:%s",filename)     }     else console_print(id,"file exist") }
__________________
schnitzelmaker is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 08-25-2007 , 23:46   Re: Re-Making FOpen?
Reply With Quote #4

Quote:
Originally Posted by schnitzelmaker View Post
Here is an Example how you can access higher/ another folder than the mod folder with amxx .
http://forums.alliedmods.net/showpos...55&postcount=7
Oh wow, I didn't know you can even do that. Thanks.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode