StripNewLine Function
#4

Quote:
Originally Posted by tyler12
Посмотреть сообщение
PHP код:
stock DINI_StripNewLine(string[]) {
    new 
len strlen(string);
    if (
string[0]==0) return ;
    if ((
string[len 1] == '\n') || (string[len 1] == '\r')) {
        
string[len 1] = 0;
        if (
string[0]==0) return ;
        if ((
string[len 2] == '\n') || (string[len 2] == '\r')) string[len 2] = 0;
    }
}
stock DINI_fcopytextfile(oldname[],newname[]) {
    new 
File:ohnd,File:nhnd;
    if (!
fexist(oldname)) return false;
    
ohnd=fopen(oldname,io_read);
    if (!
ohnd) return false;
    
nhnd=fopen(newname,io_write);
    if (!
nhnd) {
        
fclose(ohnd);
        return 
false;
    }
    new 
tmpres[DINI_MAX_STRING];
    while (
fread(ohnd,tmpres)) {
        
DINI_StripNewLine(tmpres);
        
format(tmpres,sizeof(tmpres),"%s\r\n",tmpres);
        
fwrite(nhnd,tmpres);
    }
    
fclose(ohnd);
    
fclose(nhnd);
    return 
true;

- Dracoblue (Dini).

OffTopic; Rofl @ Signature.
Thanks!
Reply


Messages In This Thread
StripNewLine Function - by dr.lozer - 06.12.2012, 13:47
Re: StripNewLine Function - by Roel - 06.12.2012, 14:24
Re: StripNewLine Function - by tyler12 - 06.12.2012, 14:29
Re: StripNewLine Function - by dr.lozer - 06.12.2012, 14:45

Forum Jump:


Users browsing this thread: 1 Guest(s)