secureswitools/swisistools/source/rscparser/parse.cpp
changeset 60 245df5276b97
parent 25 98b66e4fb0be
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
   203 
   203 
   204 std::string ParsePtrC::Name()
   204 std::string ParsePtrC::Name()
   205 {
   205 {
   206   string iName;
   206   string iName;
   207 
   207 
       
   208   #ifdef __LINUX__
       
   209   TInt i = Buf->rfind("/");
       
   210   #else
   208   TInt i = Buf->rfind("\\");
   211   TInt i = Buf->rfind("\\");
       
   212   #endif
       
   213 
   209   if(i!=string::npos)
   214   if(i!=string::npos)
   210      iName.assign(*Buf, i, Buf->size()-4);
   215      iName.assign(*Buf, i, Buf->size()-4);
   211   else
   216   else
   212   {
   217   {
   213 	  if(ExtPresent())
   218 	  if(ExtPresent())
   221 
   226 
   222 std::string ParsePtrC::NameAndExt()
   227 std::string ParsePtrC::NameAndExt()
   223 {
   228 {
   224   string iName;
   229   string iName;
   225 
   230 
       
   231   #ifdef __LINUX__
       
   232   TInt i = Buf->rfind("/");
       
   233   #else
   226   TInt i = Buf->rfind("\\");
   234   TInt i = Buf->rfind("\\");
       
   235   #endif
       
   236   
   227   if(i!=string::npos)
   237   if(i!=string::npos)
   228      iName.assign(*Buf, i, Buf->size());
   238      iName.assign(*Buf, i, Buf->size());
   229 
   239 
   230    return iName;
   240    return iName;
   231 }
   241 }
   232 
   242 
   233 std::string ParsePtrC::FullPath()
   243 std::string ParsePtrC::FullPath()
   234 {
   244 {
   235   string iName;
   245   string iName;
   236 
   246 
       
   247   #ifdef __LINUX__
       
   248   TInt i = Buf->rfind("/");
       
   249   #else
   237   TInt i = Buf->rfind("\\");
   250   TInt i = Buf->rfind("\\");
       
   251   #endif
       
   252   
   238   if(i!=string::npos)
   253   if(i!=string::npos)
   239      iName.assign(*Buf, 0, i);
   254      iName.assign(*Buf, 0, i);
   240 
   255 
   241    return iName;
   256    return iName;
   242 }
   257 }
   243 
   258 
   244 std::string ParsePtrC::Path()
   259 std::string ParsePtrC::Path()
   245 {
   260 {
   246   string iName;
   261   string iName;
   247 
   262 
       
   263   #ifdef __LINUX__
       
   264   TInt j = Buf->rfind("/");
       
   265   TInt i = Buf->find("/");
       
   266   #else
   248   TInt j = Buf->rfind("\\");
   267   TInt j = Buf->rfind("\\");
   249   TInt i = Buf->find("\\");
   268   TInt i = Buf->find("\\");
       
   269   #endif
       
   270 
   250   if(i!=string::npos)
   271   if(i!=string::npos)
   251      iName.assign(*Buf, i, Buf->size()-j);
   272      iName.assign(*Buf, i, Buf->size()-j);
   252 
   273 
   253    return iName;
   274    return iName;
   254 }
   275 }
   275    return iName;
   296    return iName;
   276 }
   297 }
   277 
   298 
   278 TInt ParsePtrC::NamePresent()
   299 TInt ParsePtrC::NamePresent()
   279 {
   300 {
       
   301 	#ifdef __LINUX__
       
   302 	TInt i = Buf->rfind("/");
       
   303     #else
   280 	TInt i = Buf->rfind("\\");
   304 	TInt i = Buf->rfind("\\");
       
   305     #endif
       
   306 
   281 	if(i!=string::npos)
   307 	if(i!=string::npos)
   282 		iNamePresent = 1;
   308 		iNamePresent = 1;
   283 	else
   309 	else
   284 	{
   310 	{
   285 		if(Buf!= NULL)
   311 		if(Buf!= NULL)
   290 	return iNamePresent;
   316 	return iNamePresent;
   291 }
   317 }
   292 
   318 
   293 TInt ParsePtrC::PathPresent()
   319 TInt ParsePtrC::PathPresent()
   294 {
   320 {
       
   321 	#ifdef __LINUX__
       
   322 	TInt i = Buf->find("/");
       
   323 	#else
   295 	TInt i = Buf->find("\\");
   324 	TInt i = Buf->find("\\");
       
   325 	#endif
       
   326 
   296 	if(i!=string::npos)
   327 	if(i!=string::npos)
   297 		iPathPresent = 1;
   328 		iPathPresent = 1;
   298 	else
   329 	else
   299 		iPathPresent = 0;
   330 		iPathPresent = 0;
   300 	return iPathPresent;
   331 	return iPathPresent;
   328 	return 0;
   359 	return 0;
   329 }
   360 }
   330 
   361 
   331 TInt ParsePtrC::IsValidName()
   362 TInt ParsePtrC::IsValidName()
   332 {
   363 {
   333 	string::size_type index = Buf->find_last_of("*?< > : \" / |");
   364 	#ifdef __LINUX__
       
   365 	    string::size_type index = Buf->find_last_of("*?< > : \" \\ |");
       
   366 	#else
       
   367 	    string::size_type index = Buf->find_last_of("*?< > : \" |");
       
   368 	#endif
       
   369 
   334 	if( index != string::npos )
   370 	if( index != string::npos )
   335 		return 1;
   371 		return 1;
   336 	return 0;
   372 	return 0;
   337 }
   373 }