Raised This Month: $ Target: $400
 0% 

write_file "Couldn't create temp file"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elusive138
Senior Member
Join Date: Dec 2010
Old 12-28-2010 , 04:02   write_file "Couldn't create temp file"
Reply With Quote #1

Hi

I need to be able to read origins from a file and write new origins to the same file. To do this I've used
PHP Code:
format(writeLinecharsmax(writeLine), "%s CT,%f,%f,%f"writeLinegCtOrigin[0], gCtOrigin[1], gCtOrigin[2]) 
to format a string which I then write with
PHP Code:
write_file(gSpawnsFilewriteLinegFileLine
This works when I'm writing a new line (where gFileLine = -1, which means the line didn't exist when I read it) but if I try to overwrite an existing line (gFileLine >= 0), I get an error:
Code:
L 12/28/2010 - 19:52:19: Couldn't create temp file
L 12/28/2010 - 19:52:19: [AMXX] Displaying debug trace (plugin "DefendTheVIP.amxx")
L 12/28/2010 - 19:52:19: [AMXX] Run time error 10: native error (native "write_file")
L 12/28/2010 - 19:52:19: [AMXX]    [0] DefendTheVIP.sma::WriteFile (line
Any help with this would be much appreciated!

Thanks.
Elusive138 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-28-2010 , 04:24   Re: write_file "Couldn't create temp file"
Reply With Quote #2

Do you rent a server ?
I think the problem is more ftp rights than your code.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Elusive138
Senior Member
Join Date: Dec 2010
Old 12-28-2010 , 04:36   Re: write_file "Couldn't create temp file"
Reply With Quote #3

It's a listenserver, running on my computer (Vista). My account has "Full Control" over the file in question. I'm pretty sure it's not an access control problem.

I find it easier to test new, half-written plugins on my own computer, not that I have any other server

Thanks.
Elusive138 is offline
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 12-28-2010 , 05:06   Re: write_file "Couldn't create temp file"
Reply With Quote #4

I think, hlds (or listen server) doesn't have rights to write tmp file in C:\ dir.

Last edited by Flipper_SPb; 12-28-2010 at 05:08.
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 12-28-2010 , 05:12   Re: write_file "Couldn't create temp file"
Reply With Quote #5

I had the same problem. But I run server with limited access...
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Elusive138
Senior Member
Join Date: Dec 2010
Old 12-28-2010 , 05:13   Re: write_file "Couldn't create temp file"
Reply With Quote #6

Quote:
Originally Posted by Flipper_SPb View Post
I think, hlds (or listen server) doesn't have rights to write tmp file in C:\ dir.
What? If amxmodx needs access above the game directory, just to edit a file (which I remind you I have no problems writing a new line to, just can't overwrite existing lines), then there's something seriously wrong.

EDIT: I just double checked, by forcing full permissions for the root drive, and "Run As Administrator". Still no.. sorry.

Last edited by Elusive138; 12-28-2010 at 06:06.
Elusive138 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-28-2010 , 05:47   Re: write_file "Couldn't create temp file"
Reply With Quote #7

When you overwrite a line, amxx needs to create a temp file to copy original file datas, and then the original file is completely rewritten.

Code:
	// adding a new line in a middle of already existing file
	FILE* pTemp;
	char buffor[2048];

	if ((pTemp = tmpfile()) == NULL)
	{
		LogError(amx, AMX_ERR_NATIVE, "Couldn't create temp file");
		return 0;
	}
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Elusive138
Senior Member
Join Date: Dec 2010
Old 12-28-2010 , 05:55   Re: write_file "Couldn't create temp file"
Reply With Quote #8

Do you know where that temp file is created and/or why I can't seem to create one?

Also, if anyone has an alternative method to save (modifiable) origins for spawning entities?

Thanks!

Last edited by Elusive138; 12-28-2010 at 06:02.
Elusive138 is offline
Flipper_SPb
Senior Member
Join Date: Jun 2009
Location: Worldspawn
Old 12-28-2010 , 08:32   Re: write_file "Couldn't create temp file"
Reply With Quote #9

Quote:
Originally Posted by Elusive138 View Post
Do you know where that temp file is created

For Windows XP/2003 it is root of system partition (С:\)
Not sure with Win Vista/7
Flipper_SPb is offline
Send a message via ICQ to Flipper_SPb
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-28-2010 , 13:18   Re: write_file "Couldn't create temp file"
Reply With Quote #10

Quote:
Originally Posted by Elusive138 View Post
Do you know where that temp file is created and/or why I can't seem to create one?

Also, if anyone has an alternative method to save (modifiable) origins for spawning entities?

Thanks!
Maybe because you don't have specific permissions to write in that directory?

The alternative would be to use the new file natives (fopen, fputs, etc.).
When saving, read the whole file data into variables, then write to the file again with all of the updated data.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
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 01:58.


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