Raised This Month: $ Target: $400
 0% 

help on search and edit [simple i think]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sn4k3
Senior Member
Join Date: Nov 2005
Old 07-22-2007 , 08:17   help on search and edit [simple i think]
Reply With Quote #1

how can i do that:

const char *text = "file/path/file/name.txt";

this is for use in a concommand

path is user choise!

now can i find the filename ONLY ?
sn4k3 is offline
Send a message via MSN to sn4k3
3jorn
Junior Member
Join Date: May 2007
Old 07-22-2007 , 09:12   Re: help on search and edit [simple i think]
Reply With Quote #2

Try exploding the string by "/" (slashes) and take the last index in your array. That will be your filename
3jorn is offline
sn4k3
Senior Member
Join Date: Nov 2005
Old 07-22-2007 , 11:19   Re: help on search and edit [simple i think]
Reply With Quote #3

Quote:
Originally Posted by 3jorn View Post
Try exploding the string by "/" (slashes) and take the last index in your array. That will be your filename
any example?
sn4k3 is offline
Send a message via MSN to sn4k3
3jorn
Junior Member
Join Date: May 2007
Old 07-22-2007 , 11:44   Re: help on search and edit [simple i think]
Reply With Quote #4

Try this: http://www.gammon.com.au/forum/?id=5587

I'm afraid I don't have time the next couple of days to cook up an example, but use google and reuse already written code ;)
3jorn is offline
mooman2
Member
Join Date: Apr 2007
Old 07-22-2007 , 12:07   Re: help on search and edit [simple i think]
Reply With Quote #5

include string.h and use strtok()

http://www.cplusplus.com/reference/c...ng/strtok.html
mooman2 is offline
sn4k3
Senior Member
Join Date: Nov 2005
Old 07-22-2007 , 13:37   Re: help on search and edit [simple i think]
Reply With Quote #6

Quote:
Originally Posted by mooman2 View Post
yeah i forgot that function
sn4k3 is offline
Send a message via MSN to sn4k3
3jorn
Junior Member
Join Date: May 2007
Old 07-22-2007 , 16:56   Re: help on search and edit [simple i think]
Reply With Quote #7

Sorry, I'm more accustomed to PHP programming than C++, but after doing quick research on explode for CSS I see many recommending looking at tokens instead.

Good call mooman2
3jorn is offline
sn4k3
Senior Member
Join Date: Nov 2005
Old 07-23-2007 , 08:08   Re: help on search and edit [simple i think]
Reply With Quote #8

this work but remove all other paths!!!!!!!

Code:
char *SU_Get_FileText(char *text)
{
	char *pch = text;
	pch = strtok(pch,"/");
	char *oldpch = text;
	while (pch != NULL)
	{
		oldpch = pch;
		pch = strtok (NULL, "/");
	}
	return oldpch;
}

void SU_File_Remove(const char *filename)
{
	char *newfile = SU_Get_FileText((char *)filename);

	Msg("FILE: %s\n",filename);

	if(newfile[0] != 's' || newfile[1] != 'u' || newfile[2] != '_')
		StrReplace((char *)filename,newfile,UTIL_VarArgs("su_%s",newfile),sizeof(char *));

	Msg("FILE: %s\n",filename);

	if(!filesystem->FileExists(filename,"MOD"))
	{
		Msg("SU: File '%s' Not Exists\n",filename);
		return ;
	}
	filesystem->RemoveFile(filename,"MOD");
}
after in game!!


Quote:
] su_file remove cfg/s.cfg
FILE: cfg
FILE: cfg
Unable to remove h:\bck200\caza\jogos\servers\cstrike\cfg!
i have debuged "newfile" too and say correct file

newfile = s.cfg

why this happen!?

Last edited by sn4k3; 07-23-2007 at 08:12.
sn4k3 is offline
Send a message via MSN to sn4k3
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 07:54.


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