Revision: 201007 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Mon, 15 Mar 2010 12:46:24 +0200
branchRCL_3
changeset 10 3a3c1a7fa1e8
parent 9 fa985af77159
child 15 18da5738c9b6
Revision: 201007 Kit: 201010
genericopenlibs/openenvcore/include/wchar.h
genericopenlibs/openenvcore/libc/src/wfindfirst.cpp
genericservices/s60compatibilityheaders/hwrm/HWRMPluginService.inl
genericservices/taskscheduler/group/backup_registration.xml
--- a/genericopenlibs/openenvcore/include/wchar.h	Fri Mar 12 15:50:56 2010 +0200
+++ b/genericopenlibs/openenvcore/include/wchar.h	Mon Mar 15 12:46:24 2010 +0200
@@ -337,6 +337,7 @@
 #define _A_NORMAL 0x0000	//Normal. File has no other attributes set and can be read or written to without restriction. Value: 0x00.
 #define _A_RDONLY 0x0001		//Read-only. File cannot be opened for writing and a file with the same name cannot be created. Value: 0x01.
 #define _A_SYSTEM  0x0004		//System file. Not normally seen with the DIR command, unless the /A or /A:S option is used
+#define _A_SUBDIR 0x0010        // Subdirectory.        
 
 IMPORT_C size_t	wcslcat(wchar_t *, const wchar_t *, size_t);
 IMPORT_C size_t	 wcslcpy(wchar_t *, const wchar_t *, size_t);
--- a/genericopenlibs/openenvcore/libc/src/wfindfirst.cpp	Fri Mar 12 15:50:56 2010 +0200
+++ b/genericopenlibs/openenvcore/libc/src/wfindfirst.cpp	Mon Mar 15 12:46:24 2010 +0200
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -67,68 +67,115 @@
 
 #include <stdlib.h>
 #include <wchar.h>
-#include <bafindf.h>
 #include <errno.h> 
 #include "sysif.h"
-
+#include<e32base.h>
 #include<e32cmn.h>
 #include<ltime.h>
-#define	MAXPATHLEN	260	
+#define MAXPATHLEN  260 
+#define ATTMASK (_A_ARCH|_A_HIDDEN|_A_NORMAL|_A_RDONLY|_A_SYSTEM|_A_SUBDIR )
+
+class CFindFileByPath : public CBase
+    {
+    public:
+        CFindFileByPath(RFs& aFs) : iFinder(aFs),iLastCount(-1)
+            {  
+            }
+        ~CFindFileByPath()
+            {
+            delete iDir;
+            iDir = NULL;
+            }
+        const TEntry& Entry()
+            {
+            return (*iDir)[iLastCount];
+            }
+        TInt FindFirst(const TDesC&,const TDesC&);
+        TInt FindNext();
+    private:
+        TFindFile iFinder;
+        CDir* iDir;
+        TInt iLastCount;
+        TBuf<MAXPATHLEN> iPath;
+    };
+
+TInt CFindFileByPath::FindFirst(const TDesC &aPattern, const TDesC& aPath)
+    {
+    iPath = aPath;
+    TInt ret = iFinder.FindWildByPath(aPattern,&iPath,iDir);
+    if(ret != KErrNone)
+        {
+        return ret;
+        }
+    return FindNext();
+    }
+
+TInt CFindFileByPath::FindNext()
+    {
+    TInt count = iDir->Count();
+//    Results from the search either in pattern path or in the cwd.
+    if(++iLastCount<count)
+        {
+        return KErrNone;
+        }
+    return KErrNotFound;
+    }
+
+void UpdateFileInfo(struct _wfinddata_t* aFileinfo, CFindFileByPath& aFinder)
+    {
+    wcscpy(aFileinfo->name ,(wchar_t *)aFinder.Entry().iName.Ptr());
+    TInt k = aFinder.Entry().iName.Size()/sizeof(wchar_t);
+    aFileinfo->name[k] = L'\0';
+
+
+    aFileinfo->size = aFinder.Entry().iSize;
+
+    // Unmask unnecessary attributes in iAtt. 
+    // All constant definitions are in sync with what is expected in finddata structure.
+    aFileinfo->attrib = aFinder.Entry().iAtt;    
+    aFileinfo->attrib &= (ATTMASK);
+
+    time_t time_modify = as_time_t(aFinder.Entry().iModified); 
+    aFileinfo->time_write = time_modify;
+
+    aFileinfo->time_create = -1L;
+    aFileinfo->time_access = -1L;
+
+    }
 
 extern "C" 
 {
-	 //RFs FileServerSession ; 
+     //RFs FileServerSession ; 
 EXPORT_C intptr_t wfindfirst(const wchar_t*  filespec, struct _wfinddata_t* fileinfo)
  {
    
    if(!filespec||!fileinfo)
    return EINVAL;
    
-   long handle = -1;	
+   long handle = -1;    
    wchar_t *dirf =(wchar_t*)malloc(MAXPATHLEN * sizeof(wchar_t)); // getting the cuurent directory
    wgetcwd(dirf,MAXPATHLEN);
    TPtrC16 dird((const TUint16*)dirf); // converting it into descriptor
    TPtrC16 fsd((const TUint16*)filespec );
-   TUidType uid(KNullUid, KNullUid, KNullUid);
-   //FileServerSession.Connect() ;	
-   
-   CFindFileByType *temp1= new CFindFileByType(Backend()->FileSession()); // #include <bafindf.h> 	
+ 
+   CFindFileByPath *temp1= new CFindFileByPath(Backend()->FileSession());    
    if(temp1== NULL)
-   {
-  		return EINVAL;
-  	}
-   int k = temp1->FindFirst(fsd,dird,uid);
+       {
+       return EINVAL;
+       }
+   int k = temp1->FindFirst(fsd,dird);
    if(k==KErrNone)
-   {
-   	    	
-   	wcscpy(fileinfo->name ,(wchar_t *)temp1->Entry().iName.Ptr());
-   	k = temp1->Entry().iName.Size()/sizeof(wchar_t);
-   	fileinfo->name[k] = L'\0';
-   	
-   	
-   	fileinfo->size = temp1->Entry().iSize;
-   	
-   	fileinfo->attrib = temp1->Entry().iAtt; // we have to eport defined 
-   	//also like KEntryAttNormal all this are availabel in f32file.h one 
-   	//attribte _A_SUBDIR will not be suuported 
-
-   	time_t time_modify = as_time_t(temp1->Entry().iModified); 
-    fileinfo->time_write = time_modify;
-    
-   	fileinfo->time_create = -1L;
-   	fileinfo->time_access = -1L;
-   	
-   	
-   	handle = reinterpret_cast<long>(temp1);
-   }
+       {        
+       UpdateFileInfo(fileinfo,*temp1);
+       handle = reinterpret_cast<long>(temp1);
+       }
    else
-   {
-   	handle = -1;
-  	errno = ENOENT ;
-   }
-   delete dirf; // delete directory pointer	
-   //FileServerSession.Close(); 
- 
+       {
+        handle = -1;
+        delete temp1;
+        errno = ENOENT ;
+       }
+   delete dirf; // delete directory pointer 
    return handle;
  
  }
@@ -136,37 +183,33 @@
 
 EXPORT_C intptr_t wfindnext(intptr_t handle, struct _wfinddata_t * fileinfo)
  {
- 		if((handle<=0)||!fileinfo)
-   	return EINVAL;	
- 	
- 	CFindFileByType *temp1 = reinterpret_cast<CFindFileByType *>(handle); 
- 	int k = temp1->FindNext();
- 	if(KErrNone==k)
- 	{
- 		wcscpy(fileinfo->name , (wchar_t *)temp1->Entry().iName.Ptr());
- 		k = temp1->Entry().iName.Size()/sizeof(wchar_t);
-   	fileinfo->name[k] = L'\0';
-   	fileinfo->size = temp1->Entry().iSize;
-   	return 0;	
- 	}
- 	else 
- 	{
- 	 	errno = ENOENT ;
-	 	return -1;
-	}
+        if((handle<=0)||!fileinfo)
+    return EINVAL;  
+    
+    CFindFileByPath *temp1 = reinterpret_cast<CFindFileByPath *>(handle); 
+    int k = temp1->FindNext();
+    if(KErrNone==k)
+    {
+    UpdateFileInfo(fileinfo,*temp1);
+    return 0;   
+    }
+    else 
+    {
+        errno = ENOENT ;
+        return -1;
+    }
  }
-	
+    
  EXPORT_C int findclose( intptr_t handle)
  {
- 	if(handle <=0)
- 	{
-		errno = ENOENT ;
-	 	return -1;
- 	}
- 	CFindFileByType *temp1 = reinterpret_cast<CFindFileByType *>(handle); 
- //FileServerSession.Close(); 
- 	delete temp1;
- 	return 0;
+    if(handle <=0)
+    {
+        errno = ENOENT ;
+        return -1;
+    }
+    CFindFileByPath *temp1 = reinterpret_cast<CFindFileByPath *>(handle); 
+    delete temp1;
+    return 0;
   }
 } 
 
--- a/genericservices/s60compatibilityheaders/hwrm/HWRMPluginService.inl	Fri Mar 12 15:50:56 2010 +0200
+++ b/genericservices/s60compatibilityheaders/hwrm/HWRMPluginService.inl	Mon Mar 15 12:46:24 2010 +0200
@@ -11,15 +11,6 @@
 // Contributors:
 //
 // Description:
-// All rights reserved.
-// This component and the accompanying materials are made available
-// under the terms of the License "Eclipse Public License v1.0"
-// which accompanies this distribution, and is available
-// at the URL "http://www.eclipse.org/legal/epl-v10.html".
-// Initial Contributors:
-// Nokia Corporation - initial contribution.
-// Contributors:
-//
 
 // stub header file - use Symbian supplied version instead
 #include <hwrm/hwrmpluginservice.inl>
--- a/genericservices/taskscheduler/group/backup_registration.xml	Fri Mar 12 15:50:56 2010 +0200
+++ b/genericservices/taskscheduler/group/backup_registration.xml	Mon Mar 15 12:46:24 2010 +0200
@@ -2,10 +2,10 @@
 <!--
  Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
  All rights reserved.
- This component and the accompanying materials are made available
- under the terms of the License "Eclipse Public License v1.0"
- which accompanies this distribution, and is available
- at the URL "http://www.eclipse.org/legal/epl-v10.html".
+This component and the accompanying materials are made available
+under the terms of the License "Eclipse Public License v1.0"
+which accompanies this distribution, and is available
+at the URL "http://www.eclipse.org/legal/epl-v10.html".
 
  Initial Contributors:
  Nokia Corporation - initial contribution.