// Convert the deletion date to the number of seconds since the epoch // The string representing the deletion date must be in the format YYYY-MM-DDThh:mm:ss long deltime(FXString delstr) { // Decompose the date into year, month, day, hour, minutes and seconds FXString year=delstr.mid(0,4); FXString mon=delstr.mid(5,2); FXString mday=delstr.mid(8,2); FXString hour=delstr.mid(11,2); FXString min=delstr.mid(14,2); FXString sec=delstr.mid(17,2); // Convert date using mktime() tm tmval; tmval.tm_sec=atoi(sec.text()); tmval.tm_min=atoi(min.text()); tmval.tm_hour=atoi(hour.text()); tmval.tm_mday=atoi(mday.text()); tmval.tm_mon=atoi(mon.text()); tmval.tm_year=atoi(year.text())-1900; tmval.tm_isdst=0; long t=(long)mktime(&tmval); // If conversion failed, return 0 if (t<0) t=0; return t; }
// Obtain file path from URI specified as file:///bla/bla/bla... // If no 'file:' prefix is found, return the input string as is FXString fileFromURI(FXString uri) { if(comparecase("file:",uri,5)==0) { if(uri[5]==PATHSEPCHAR && uri[6]==PATHSEPCHAR) return uri.mid(7,uri.length()-7); return uri.mid(5,uri.length()-5); } return uri; }
// Strip pattern from text if present FXString FXFileSelector::patternFromText(const FXString& pattern){ FXint beg,end; end=pattern.rfind(')'); // Search from the end so we can allow ( ) in the pattern name itself beg=pattern.rfind('(',end-1); if(0<=beg && beg<end) return pattern.mid(beg+1,end-beg-1); return pattern; }
void ap_parse_pls(const FXString & data,FXStringList & mrl) { FXint start=0,end=0,pos,next; for (FXint i=0;i<data.length();i++) { if (data[i]=='\n') { end=i; next=i+1; /// Skip white space while(start<end && Ascii::isSpace(data[start])) start++; /// Skip white space while(end>start && Ascii::isSpace(data[end])) end--; /// Parse the actual line. if ((end-start)>6) { if (compare(&data[start],"File",4)==0) { pos = data.find('=',start+4); if (pos==-1) continue; pos++; if (end-pos>0) { mrl.append(data.mid(pos,1+end-pos)); } } } start=next; } } }
// Return the first extension "ext1" found in the pattern if the // pattern is of the form "*.ext1,*.ext2,..." or the empty string // if the pattern contains other wildcard combinations. FXString FXFileSelector::extensionFromPattern(const FXString& pattern){ FXint beg,end,c; beg=0; if(pattern[beg]=='*'){ beg++; if(pattern[beg]=='.'){ beg++; end=beg; while((c=pattern[end])!='\0' && c!=',' && c!='|'){ if(c=='*' || c=='?' || c=='[' || c==']' || c=='^' || c=='!') return FXString::null; end++; } return pattern.mid(beg,end-beg); } } return FXString::null; }