core/src/commands.cpp
changeset 66 2a78c4ff2eab
parent 59 c9dfb364c2d1
child 69 849a0b46c767
equal deleted inserted replaced
63:6a2083f7eeb8 66:2a78c4ff2eab
   226 			}
   226 			}
   227 		else
   227 		else
   228 			{
   228 			{
   229 			iFormatter->AppendFormatL(_L("%+ 10d  "), aEntry.iSize);
   229 			iFormatter->AppendFormatL(_L("%+ 10d  "), aEntry.iSize);
   230 			}
   230 			}
   231 		aEntry.iModified.FormatL(iTempBuf, _L("%1%/1%2%/2%3 %H%:1%T%:2%S "));
   231 		if (iOptNoLocalise)
       
   232 			{
       
   233 			iTempBuf.Format(_L("%+ 19Ld "), aEntry.iModified.Int64()); // 19 so the output is the same width whether or not iOptNoLocalise is specified (assuming roughly European date settings)
       
   234 			}
       
   235 		else
       
   236 			{
       
   237 			aEntry.iModified.FormatL(iTempBuf, _L("%1%/1%2%/2%3 %H%:1%T%:2%S "));
       
   238 			}
   232 		TPtrC pathRelativeToBaseDir = iFileName.Mid(iBaseDir.Length());
   239 		TPtrC pathRelativeToBaseDir = iFileName.Mid(iBaseDir.Length());
   233 		iFormatter->AppendFormatL(_L("%S%S%S\r\n"), &iTempBuf, &pathRelativeToBaseDir, &aEntry.iName);
   240 		iFormatter->AppendFormatL(_L("%S%S%S\r\n"), &iTempBuf, &pathRelativeToBaseDir, &aEntry.iName);
   234 		}
   241 		}
   235 	else
   242 	else
   236 		{
   243 		{
   287 	{
   294 	{
   288 	_LIT(KCmdLsOptAll, "all");
   295 	_LIT(KCmdLsOptAll, "all");
   289 	_LIT(KCmdLsOptLong, "long");
   296 	_LIT(KCmdLsOptLong, "long");
   290 	_LIT(KCmdLsOptHuman, "human");
   297 	_LIT(KCmdLsOptHuman, "human");
   291 	_LIT(KCmdLsOptOnePerLine, "one");
   298 	_LIT(KCmdLsOptOnePerLine, "one");
   292 	_LIT(KCmdLsOpRecurse, "recurse");
   299 	_LIT(KCmdLsOptRecurse, "recurse");
       
   300 	_LIT(KCmdLsOptNoLocalise, "no-localise");
   293 
   301 
   294 	aOptions.AppendBoolL(iOptAll, KCmdLsOptAll);
   302 	aOptions.AppendBoolL(iOptAll, KCmdLsOptAll);
   295 	aOptions.AppendBoolL(iOptLong, KCmdLsOptLong);
   303 	aOptions.AppendBoolL(iOptLong, KCmdLsOptLong);
   296 	aOptions.AppendBoolL(iOptHuman, KCmdLsOptHuman);
   304 	aOptions.AppendBoolL(iOptHuman, KCmdLsOptHuman);
   297 	aOptions.AppendBoolL(iOptOnePerLine, KCmdLsOptOnePerLine);
   305 	aOptions.AppendBoolL(iOptOnePerLine, KCmdLsOptOnePerLine);
   298 	aOptions.AppendBoolL(iOptRecurse, KCmdLsOpRecurse);
   306 	aOptions.AppendBoolL(iOptRecurse, KCmdLsOptRecurse);
       
   307 	aOptions.AppendBoolL(iOptNoLocalise, KCmdLsOptNoLocalise);
   299 	}
   308 	}
   300 
   309 
   301 void CCmdLs::ArgumentsL(RCommandArgumentList& aArguments)
   310 void CCmdLs::ArgumentsL(RCommandArgumentList& aArguments)
   302 	{
   311 	{
   303 	_LIT(KCmdLsArg, "dir_name");
   312 	_LIT(KCmdLsArg, "dir_name");
   732 	const TInt numFiles = iFileNames.Count();
   741 	const TInt numFiles = iFileNames.Count();
   733 	for (TInt i = 0; i < numFiles; ++i)
   742 	for (TInt i = 0; i < numFiles; ++i)
   734 		{
   743 		{
   735 		TFileName2& fileName = iFileNames[i];
   744 		TFileName2& fileName = iFileNames[i];
   736 		LeaveIfFileNotFound(fileName);
   745 		LeaveIfFileNotFound(fileName);
   737 		if (iRecurse)
   746 		if (fileName.IsDirL(FsL()))
   738 			{
   747 			{
   739 			if (fileName.IsDirL(FsL()))
   748 			if (iRecurse)
   740 				{
   749 				{
   741 				fileName.SetTypeL(TFileName2::EDirectory);
   750 				fileName.SetTypeL(TFileName2::EDirectory);
   742 				}
   751 				}
   743 			else
   752 			else
   744 				{
   753 				{
   745 				PrintError(KErrArgument, _L("Invalid use of \"-r\" option - \"%S\" is not a directory."), &fileName);
   754 				PrintError(KErrArgument, _L("Couldn't remove \"%S\" because it is a directory - use \"rm -r\" or \"rmdir\" instead."), &fileName);
   746 				User::Leave(KErrArgument);
   755 				User::Leave(KErrArgument);
   747 				}
   756 				}
   748 			}
       
   749 		else if (fileName.IsDirL(FsL()))
       
   750 			{
       
   751 			PrintError(KErrArgument, _L("Couldn't remove \"%S\" because it is a directory - use \"rm -r\" or \"rmdir\" instead."), &fileName);
       
   752 			User::Leave(KErrArgument);
       
   753 			}
   757 			}
   754 
   758 
   755 		TInt err = DoDelete(fileName);
   759 		TInt err = DoDelete(fileName);
   756 		if (err == KErrAccessDenied && iForce)
   760 		if (err == KErrAccessDenied && iForce)
   757 			{
   761 			{
   774 	}
   778 	}
   775 
   779 
   776 TInt CCmdRm::DoDelete(const TDesC& aFileName)
   780 TInt CCmdRm::DoDelete(const TDesC& aFileName)
   777 	{
   781 	{
   778 	TInt err;
   782 	TInt err;
   779 	if (iRecurse)
   783 	if (iRecurse && aFileName[aFileName.Length()-1] == '\\')
   780 		{
   784 		{
   781 		err = iFileMan->RmDir(aFileName);
   785 		err = iFileMan->RmDir(aFileName);
   782 		}
   786 		}
   783 	else
   787 	else
   784 		{
   788 		{
  2382 void CCmdDate::Display(const TTime& aTime)
  2386 void CCmdDate::Display(const TTime& aTime)
  2383 	{
  2387 	{
  2384 	if (iRaw)
  2388 	if (iRaw)
  2385 		{
  2389 		{
  2386 		TInt64 time = aTime.Int64();
  2390 		TInt64 time = aTime.Int64();
  2387 		if (iUseKernelFormat) time += KY2kInMicroSeconds;
  2391 		if (iUseY2k) time -= KY2kInMicroSeconds;
  2388 		Printf(_L("%Ld\r\n"), time);
  2392 		Printf(_L("%Ld\r\n"), time);
  2389 		}
  2393 		}
  2390 	else if (iUseTimestampFormat)
  2394 	else if (iUseTimestampFormat)
  2391 		{
  2395 		{
  2392 		TDateTime dateTime(aTime.DateTime());
  2396 		TDateTime dateTime(aTime.DateTime());
  2439 		Display(time);
  2443 		Display(time);
  2440 		}
  2444 		}
  2441 	else
  2445 	else
  2442 		{
  2446 		{
  2443 		_LIT(KSettingError, "Cannot set the time");
  2447 		_LIT(KSettingError, "Cannot set the time");
  2444 		if (iUseKernelFormat) iRawTimeToSet -= KY2kInMicroSeconds;
  2448 		if (iUseY2k) iRawTimeToSet += KY2kInMicroSeconds;
  2445 		TTime time(iRawTimeToSet);
  2449 		TTime time(iRawTimeToSet);
  2446 		if (iDateToSet)
  2450 		if (iDateToSet)
  2447 			{
  2451 			{
  2448 			_LIT(KParsingTime, "Cannot parse time string");
  2452 			_LIT(KParsingTime, "Cannot parse time string");
  2449 			LeaveIfErr(time.Parse(*iDateToSet), KParsingTime);
  2453 			LeaveIfErr(time.Parse(*iDateToSet), KParsingTime);
  2498 #endif
  2502 #endif
  2499 	_LIT(KCmdDateOptRaw, "raw");
  2503 	_LIT(KCmdDateOptRaw, "raw");
  2500 	_LIT(KCmdDateOptJustDisplay, "just-display");
  2504 	_LIT(KCmdDateOptJustDisplay, "just-display");
  2501 	_LIT(KCmdDateOptSetRaw, "raw-set");
  2505 	_LIT(KCmdDateOptSetRaw, "raw-set");
  2502 	_LIT(KCmdDateOptTimestamp, "timestamp");
  2506 	_LIT(KCmdDateOptTimestamp, "timestamp");
  2503 	_LIT(KCmdDateOptKern, "kern");
  2507 	_LIT(KCmdDateOptY2k, "y2k");
  2504 
  2508 
  2505 	aOptions.AppendBoolL(iUniversalTime, KCmdDateOptUniversal);
  2509 	aOptions.AppendBoolL(iUniversalTime, KCmdDateOptUniversal);
  2506 	aOptions.AppendStringL(iDateToSet, KCmdDateOptSet);
  2510 	aOptions.AppendStringL(iDateToSet, KCmdDateOptSet);
  2507 	aOptions.AppendIntL(iUtcOffset, KCmdDateOptUtcOffset);
  2511 	aOptions.AppendIntL(iUtcOffset, KCmdDateOptUtcOffset);
  2508 #ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
  2512 #ifdef FSHELL_CORE_SUPPORT_SECURE_TIME
  2510 #endif
  2514 #endif
  2511 	aOptions.AppendBoolL(iRaw, KCmdDateOptRaw);
  2515 	aOptions.AppendBoolL(iRaw, KCmdDateOptRaw);
  2512 	aOptions.AppendBoolL(iJustDisplay, KCmdDateOptJustDisplay);
  2516 	aOptions.AppendBoolL(iJustDisplay, KCmdDateOptJustDisplay);
  2513 	aOptions.AppendIntL(iRawTimeToSet, KCmdDateOptSetRaw);
  2517 	aOptions.AppendIntL(iRawTimeToSet, KCmdDateOptSetRaw);
  2514 	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDateOptTimestamp);
  2518 	aOptions.AppendBoolL(iUseTimestampFormat, KCmdDateOptTimestamp);
  2515 	aOptions.AppendBoolL(iUseKernelFormat, KCmdDateOptKern);
  2519 	aOptions.AppendBoolL(iUseY2k, KCmdDateOptY2k);
  2516 	}
  2520 	}
  2517 
  2521 
  2518 
  2522 
  2519 //
  2523 //
  2520 // CCmdFsck.
  2524 // CCmdFsck.