예제 #1
0
void FilesManager::SendDrivesList() const
{
	string drivesListstr;


	int dr_type;
	char dr_avail[256];
	char *temp = dr_avail;

	/* 1st we fill the buffer */
	GetLogicalDriveStrings(256, dr_avail);
	while (*temp != NULL)
	{
		string drive;
		drive += temp;
		drive += "|";
		dr_type = GetDriveType(temp);

		switch (dr_type)
		{
		case DRIVE_UNKNOWN:
			drive += "Unknown Drive type";
			break;
		case DRIVE_NO_ROOT_DIR: 
			drive += "Drive is invalid";
			break;
		case DRIVE_REMOVABLE: 
			drive += "Removable Drive";
			break;
		case DRIVE_FIXED: 
			drive += "Hard Disk";
			break;
		case DRIVE_REMOTE: 
			drive += "Network Drive";
			break;
		case DRIVE_CDROM: 
			drive += "CD-DVD Rom";
			break;
		case DRIVE_RAMDISK: 
			drive += "Ram Drive";
			break;
		}

		unique_ptr<char[]> volumeName(new char[MAX_PATH]);
		unique_ptr<char[]> filesystem(new char[MAX_PATH]);
		DWORD serialNumber = 0;
		DWORD maxComponentLen = 0;
		DWORD fileSystemFlags = 0;

		if (!GetVolumeInformation(temp, volumeName.get(), MAX_PATH, &serialNumber, &maxComponentLen, &fileSystemFlags, filesystem.get(), MAX_PATH)) {
			strcpy_s(volumeName.get(), 10, "error");
			strcpy_s(filesystem.get(), 10, "error");
		}

		drive += "|";
		drive += volumeName.get();
		drive += "|";
		drive += filesystem.get();

		temp += lstrlen(temp) + 1; // incriment the buffer
		if (drivesListstr == "") {
			drivesListstr += drive;
		}
		else {
			drivesListstr += "|#|";
			drivesListstr += drive;
		}

		packetBuilder *bld = new packetBuilder(_filesManager, drivesList);
		bld->WriteData((unsigned char*)drivesListstr.c_str(), drivesListstr.length(), _string);
		bld->FinalizePacket();
//		m_sendSerializedPacketCallback(bld->GetSerializedPacket(), bld->GetPacketSize());
		SendPacketCallback(bld);

		volumeName.reset();
		filesystem.reset();
//		delete bld;
	}
}
예제 #2
0
char *wb_nrep::normVolume( char *res)
{
  return volumeName( norm_name, res);
}
예제 #3
0
char *wb_nrep::nameName(const char *n, int ntype, char *res)
{
  static char result[512];
  int colon_added = 0;

  if ( !res)
    res = result;
  if ( ntype & cdh_mName_volume && ntype & cdh_mName_object)
    ntype |= cdh_mName_path;
  if ( ntype & cdh_mName_path && ntype & cdh_mName_attribute)
    ntype |= cdh_mName_object;
  if ( ntype & cdh_mName_volume && ntype & cdh_mName_attribute)
    ntype = ntype | cdh_mName_path | cdh_mName_object;
  strcpy( res, "");

  if ( ntype & cdh_mName_idString) {
#if 0
    if ( ntype & cdh_mName_volume) printf( "wname: volume\n");
    if ( ntype & cdh_mName_object) printf( "wname: object\n");
    if ( ntype & cdh_mName_attribute) printf( "wname: attribute\n");
#endif
    if ( !(ntype & cdh_mName_attribute)) {
      if ( ntype & cdh_mName_volume && !(ntype & cdh_mName_object))
        strcat( res, "_V");
      else if ( !(ntype & cdh_mName_volume))
        strcat( res, "_X");
      else
        strcat( res, "_O");
    }
    else
      strcat( res, "_A");
  }
  if ( ntype & cdh_mName_volume)
    volumeName( n, res + strlen(res));
  else if ( ntype & cdh_mName_ref)
    volumeName( n, res + strlen(res));
  if ( ntype & cdh_mName_path) {
    if ( ntype & cdh_mName_volume && hasVolume()) {
      strcat( res, ":");
      colon_added = 1;
    }
    pathName( n, res + strlen(res));
  }
  if ( ntype & cdh_mName_object) {
    if ( ntype & cdh_mName_path && hasPath())
      strcat( res, "-");
    else if ( ntype & cdh_mName_volume && !hasPath() && hasVolume() && !colon_added)
      strcat( res, ":");
    objectName( n, res + strlen(res));
  }
  if ( ntype & cdh_mName_attribute && hasAttribute()) {
    if ( !m_hasSuper || m_shadowed || ntype & cdh_mName_trueAttr) {
      strcat( res, ".");
      strcat( res, n + attr[0].offs);
    }
    else {
      for ( int i = 0; i < num_attr; i++) {
	if ( !attr[i].isSuper) {
	  strcat( res, ".");
	  int l = strlen(res);
	  strncat( res, n + attr[i].offs, attr[i].len);
	  if ( attr[i].index != -1)
	    sprintf( &res[ l + attr[i].len], "[%d]", attr[i].index);
	  else
	  res[ l + attr[i].len] = 0;
	}
      }
    }
  }
  return res;
}
예제 #4
0
char *wb_nrep::volume( char *res)
{
  return volumeName( oname, res);
}