Example #1
0
    QVariant FilePlacesItem::data(int role) const
    {
        if (isTopLevel()) {
            switch (role) {
                case Qt::DecorationRole:
                    return m_icon;
                case Qt::DisplayRole:
                    return m_text;
                default:
                    return QVariant();
            }
        }

        if (isDevice())
            return deviceData(role);

        return bookmarkData(role);
    }
Example #2
0
bool TmpPanel::GetFileInfoAndValidate(const wchar_t *FilePath, /*FAR_FIND_DATA*/PluginPanelItem* FindData, int Any)
{
	StrBuf ExpFilePath;
	ExpandEnvStrs(FilePath,ExpFilePath);
	wchar_t* FileName = ExpFilePath;
	ParseParam(FileName);
	StrBuf FullPath;
	GetFullPath(FileName, FullPath);
	StrBuf NtPath;
	FormNtPath(FullPath, NtPath);

	if (!FSF.LStrnicmp(FileName, L"\\\\.\\", 4) && FSF.LIsAlpha(FileName[4]) && FileName[5]==L':' && FileName[6]==0)
	{
copy_name_set_attr:
		FindData->FileAttributes = FILE_ATTRIBUTE_ARCHIVE;
copy_name:
		if (FindData->FileName)
			free((void*)FindData->FileName);

		FindData->FileName = wcsdup(FileName);
		return(TRUE);
	}

	if (isDevice(FileName, L"\\\\.\\PhysicalDrive") || isDevice(FileName, L"\\\\.\\cdrom"))
		goto copy_name_set_attr;

	if (lstrlen(FileName))
	{
		DWORD dwAttr=GetFileAttributes(NtPath);

		if (dwAttr!=INVALID_FILE_ATTRIBUTES)
		{
			WIN32_FIND_DATA wfd;
			HANDLE fff=FindFirstFile(NtPath, &wfd);

			if (fff != INVALID_HANDLE_VALUE)
			{
				WFD2FFD(wfd,*FindData);
				FindClose(fff);
				FileName = FullPath;
				goto copy_name;
			}
			else
			{
				wfd.dwFileAttributes=dwAttr;
				HANDLE hFile=CreateFile(NtPath,FILE_READ_ATTRIBUTES,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_POSIX_SEMANTICS,NULL);

				if (hFile!=INVALID_HANDLE_VALUE)
				{
					GetFileTime(hFile, &wfd.ftCreationTime, &wfd.ftLastAccessTime, &wfd.ftLastWriteTime);
					wfd.nFileSizeLow = GetFileSize(hFile, &wfd.nFileSizeHigh);
					CloseHandle(hFile);
				}

				wfd.dwReserved0=0;
				wfd.dwReserved1=0;
				WFD2FFD(wfd, *FindData);
				FileName = FullPath;
				goto copy_name;
			}
		}

		if (Any)
			goto copy_name_set_attr;
	}

	return(FALSE);
}
Example #3
0
 QString FilePlacesItem::id() const
 {
     if (isDevice())
         return m_bookmark.metaDataItem("UDI");
     return m_bookmark.metaDataItem("ID");
 }
Example #4
0
bool uBootParams_t::save( char const *fileName )
{
   bool worked = false ;
   int mode = 
#ifdef __arm__
               O_WRONLY ;
#else
               O_WRONLY | O_CREAT ;
#endif
   int fd = open( fileName, mode );
   if( 0 <= fd )
   {
      char *const writeable = new char [dataMax_];
      memset( writeable, 0, dataMax_ );
      uLong crc ;
      char *nextOut = writeable + sizeof(crc);
      listItem_t *item = head_ ;
      while( item ){
         printf( "%s==%s\n", item->name_, item->value_ );
         unsigned len = strlen(item->name_);
         memcpy(nextOut,item->name_,len);
         nextOut += len ;
         *nextOut++ = '=' ;
         len = strlen(item->value_);
         strcpy(nextOut,item->value_);
         nextOut += len + 1 ; // skip NULL
         item = item->next_ ;
      }
      if( nextOut > writeable+dataMax_){
         fprintf( stderr, "EOF error: %p > %p(%u)\n", nextOut, writeable+dataMax_, dataMax_);
         hexDumper_t dumper(writeable,nextOut-writeable,(unsigned long)writeable);
         while( dumper.nextLine() )
            printf( "%s\n", dumper.getLine() );
         assert(nextOut <= writeable+dataMax_);
      }
      crc = crc32( 0, (Bytef *)writeable+sizeof(crc), dataMax_-sizeof(crc));
      memcpy(writeable,&crc,sizeof(crc));

#ifdef __arm__
      bool bDevice = isDevice(fileName);
      if (bDevice) {
         mtd_info_t meminfo;
         if( 0 == ioctl( fd, MEMGETINFO, (unsigned long)&meminfo) )
         {
            if( (meminfo.erasesize <= dataMax_) 
                && 
                (0 == (dataMax_%meminfo.erasesize)) )
            {
               erase_info_t erase;
               erase.start = 0 ;
               erase.length = meminfo.erasesize;
               worked = true ;
               while( worked && (erase.start < dataMax_) ){
                  if( 0 == ioctl( fd, MEMERASE, (unsigned long)&erase) )
                  {
                     erase.start += meminfo.erasesize ;
                  }
                  else {
                     fprintf( stderr, "erase error %m\n" );
                     worked = false ;
                  }
               }

               if( worked ){
                  if( 0 == (unsigned)lseek( fd, 0, SEEK_SET ) )
                  {
                     unsigned numWritten = write( fd, writeable, dataMax_ );
   
                     worked = (numWritten == dataMax_ );
                  }
                  else {
                     worked = false ;
                     perror( "lseek3" );
                  }
               }
            }
            else
               fprintf( stderr, "erase size mismatch: rv %u, mi %u\n", dataMax_, meminfo.erasesize );
         }
         else
            perror( "MEMGETINFO" );
      } else {
#endif
         int numWritten = write( fd, writeable, dataMax_ );
         worked = (numWritten == dataMax_);
         if( !worked )
            perror( fileName );
#ifdef __arm__
      } // not device on ARM
#endif
      delete [] writeable ;
      close( fd );
   }
   else
      perror( fileName );

   return worked ;
}