예제 #1
0
//---------------------------------------------------------------------------
void __fastcall TCopyDialog::UpdateControls()
{
  if (!FToRemote && FLAGSET(FOptions, coAllowRemoteTransfer))
  {
    UnicodeString Directory = DirectoryEdit->Text;
    bool RemoteTransfer = (Directory.Pos(L"\\") == 0) && (Directory.Pos(L"/") > 0);
    if (RemoteTransfer != FLAGSET(FOutputOptions, cooRemoteTransfer))
    {
      FOutputOptions =
        (FOutputOptions & ~cooRemoteTransfer) |
        FLAGMASK(RemoteTransfer, cooRemoteTransfer);
      AdjustTransferControls();
    }
  }

  UnicodeString InfoStr = FCopyParams.GetInfoStr(L"; ", FCopyParamAttrs);
  CopyParamLabel->Caption = InfoStr;
  CopyParamLabel->Hint = InfoStr;
  CopyParamLabel->ShowHint =
    (CopyParamLabel->Canvas->TextWidth(InfoStr) > (CopyParamLabel->Width * 3 / 2));

  bool RemoteTransfer = FLAGSET(FOutputOptions, cooRemoteTransfer);
  EnableControl(QueueCheck2,
    ((FOptions & (coDisableQueue | coTemp)) == 0) && !RemoteTransfer);
  QueueIndividuallyCheck->Visible =
    FLAGCLEAR(FOptions, coNoQueueIndividually) &&
    QueueCheck2->Enabled && QueueCheck2->Checked &&
    (FFileList != NULL) && (FFileList->Count > 1);

  TransferSettingsButton->Style =
    FLAGCLEAR(FOptions, coDoNotUsePresets) ?
      TCustomButton::bsSplitButton : TCustomButton::bsPushButton;
}
예제 #2
0
UnicodeString getName(UnicodeString str) {
 UnicodeString name = str;

 if (name.Pos(":") > 0)
   name = name.SubString(1, name.Pos(":")-1);
 UnicodeString alphabet = L"QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890_";

 while (true) {
   if (name.Length() == 0)
     break;
   UnicodeString ch = name.SubString(name.Length(), 1);
   if (alphabet.Pos(ch) > 0 && name.Length() > 0)
     break;
   name = name.SubString(1, name.Length()-1);
 }

 UnicodeString temp_name;
 while (true) {
   if (name.Length() == 0)
     break;
   UnicodeString ch = name.SubString(name.Length(), 1);
   if (alphabet.Pos(ch) > 0 && name.Length() > 0)
     temp_name = ch + temp_name;
   else
     break;
   name = name.SubString(1, name.Length()-1);
 }

 return temp_name;
}
예제 #3
0
파일: tools.cpp 프로젝트: elfumelfu/sandbox
UnicodeString tabelaOpusa(UnicodeString Tabela)
{
    if (Tabela.Pos("clienti_") == 0)
        return "clienti_"+Tabela;
    else
    {
        int pos = Tabela.Pos("_");
        return Tabela.SubString(pos+1, Tabela.Length()-pos);
    }
}
예제 #4
0
UnicodeString ReplaceStrAll(const UnicodeString & Str, const UnicodeString & What, const UnicodeString & ByWhat)
{
  UnicodeString Result = Str;
  intptr_t Pos = Result.Pos(What);
  while (Pos > 0)
  {
    Result.Replace(Pos, What.Length(), ByWhat.c_str(), ByWhat.Length());
    Pos = Result.Pos(What);
  }
  return Result;
}
예제 #5
0
//---------------------------------------------------------------------------
void __fastcall BookmarkFolderValidateName(const UnicodeString Name,
  bool AllowEmpty)
{
  if ((!AllowEmpty && Name.IsEmpty()) || Name.Pos(L"\\"))
  {
    throw Exception(FMTLOAD(BOOKMARK_FOLDER_INVALID_NAME, (Name)));
  }
}
예제 #6
0
//---------------------------------------------------------------------------
UnicodeString __fastcall TConfiguration::TrimVersion(UnicodeString Version)
{
  while ((Version.Pos(L".") != Version.LastDelimiter(L".")) &&
    (Version.SubString(Version.Length() - 1, 2) == L".0"))
  {
    Version.SetLength(Version.Length() - 2);
  }
  return Version;
}
예제 #7
0
//---------------------------------------------------------------------------
UnicodeString TConfiguration::TrimVersion(const UnicodeString & Version) const
{
  UnicodeString Result = Version;
  while ((Result.Pos(L".") != Result.LastDelimiter(L".")) &&
    (Result.SubString(Result.Length() - 1, 2) == L".0"))
  {
    Result.SetLength(Result.Length() - 2);
  }
  return Result;
}
예제 #8
0
UnicodeString AnsiReplaceStr(const UnicodeString & Str, const UnicodeString & From,
  const UnicodeString & To)
{
  UnicodeString Result = Str;
  intptr_t Pos = 0;
  while ((Pos = Result.Pos(From)) > 0)
  {
    Result.Replace(Pos, From.Length(), To);
  }
  return Result;
}
예제 #9
0
//---------------------------------------------------------------------------
void __fastcall TCustomCommandDialog::FormCloseQuery(TObject * /*Sender*/,
  bool & /*CanClose*/)
{
  if (ModalResult == DefaultResult(this))
  {
    if ((FMode == ccmAdd) || (FMode == ccmEdit))
    {
      UnicodeString Desc = DescriptionEdit->Text;

      if (Desc.Pos(L"=") > 0)
      {
        DescriptionEdit->SetFocus();
        throw Exception(FMTLOAD(CUSTOM_COMMAND_INVALID, (L"=")));
      }

      if (((FMode == ccmAdd) || ((FMode == ccmEdit) && (Desc != FOrigDescription))) &&
          (FCustomCommandList->Find(Desc) != 0))
      {
        DescriptionEdit->SetFocus();
        throw Exception(FMTLOAD(CUSTOM_COMMAND_DUPLICATE, (Desc)));
      }
    }

    try
    {
      bool RemoteCommand = RemoteCommandButton->Checked;

      TRemoteCustomCommand RemoteCustomCommand;
      TLocalCustomCommand LocalCustomCommand;
      TFileCustomCommand * FileCustomCommand =
        (RemoteCommand ? &RemoteCustomCommand : &LocalCustomCommand);

      TInteractiveCustomCommand InteractiveCustomCommand(FileCustomCommand);

      UnicodeString Command = CommandEdit->Text;
      InteractiveCustomCommand.Validate(Command);
      Command = InteractiveCustomCommand.Complete(Command, false);
      FileCustomCommand->Validate(Command);
    }
    catch(...)
    {
      CommandEdit->SetFocus();
      throw;
    }

    if (FOnValidate)
    {
      TCustomCommandType Command;
      GetCommand(Command);
      FOnValidate(Command);
    }
  }
}
예제 #10
0
UnicodeString UnMungeIniName(const UnicodeString & Str)
{
  intptr_t P = Str.Pos(L"%3D");
  // make this fast for now
  if (P > 0)
  {
    return ReplaceStr(Str, L"%3D", L"=");
  }
  else
  {
    return Str;
  }
}
예제 #11
0
void ScanAndPrint(seakgOutput *pOutput, UnicodeString fullname) {
  TStringList *list = new TStringList();  
  list->LoadFromFile(fullname);
  int nCount = list->Count;
  for (int i = 0; i < nCount; i++)
  {
    UnicodeString str = list->Strings[i];
	  if (str.Pos(L"class") > 0 && str.Pos("__declspec") > 0) {
      UnicodeString code = str + "\r\n";
      str = str.Trim();

      UnicodeString uuid = "none";
      if (str.Pos("\"") > 0)
        uuid = str.SubString(str.Pos("\"") + 1, 36);

      UnicodeString interfacename = str.SubString(str.Pos("I"), str.Length() - str.Pos("I") + 1);
      UnicodeString interfacename2 = getName(str);
      bool bStop = false;
      int nIncr = 0;
      while (bStop == false && i < nCount) {
        i++;
        str = list->Strings[i];
        if (str.Pos("{") > 0) {
          nIncr++;
        };

        if (str.Pos("}") > 0) {
          nIncr--;
          if(nIncr == 0) bStop = true;
        };

        code += str + "\n";
      };

	  PrintDoc(pOutput, fullname, interfacename2, uuid, code);
//      std::wcout << str.c_str();
    };
  };



  /*std::wcout << "createuuidprojectname: " <<  << "\r\n";
  std::wcout << "projectname: " << projectName.c_str() << "\r\n";
  std::wcout << "fullname: " << fullname.c_str() << "\r\n";*/
};
예제 #12
0
void TCopyParamType::Load(THierarchicalStorage * Storage)
{
  SetAddXToDirectories(Storage->ReadBool("AddXToDirectories", GetAddXToDirectories()));
  GetAsciiFileMask().SetMasks(Storage->ReadString("Masks", GetAsciiFileMask().GetMasks()));
  SetFileNameCase(static_cast<TFileNameCase>(Storage->ReadInteger("FileNameCase", GetFileNameCase())));
  SetPreserveReadOnly(Storage->ReadBool("PreserveReadOnly", GetPreserveReadOnly()));
  SetPreserveTime(Storage->ReadBool("PreserveTime", GetPreserveTime()));
  SetPreserveTimeDirs(Storage->ReadBool("PreserveTimeDirs", GetPreserveTimeDirs()));
  SetPreserveRights(Storage->ReadBool("PreserveRights", GetPreserveRights()));
  SetIgnorePermErrors(Storage->ReadBool("IgnorePermErrors", GetIgnorePermErrors()));
  FRights.SetText(Storage->ReadString("Text", GetRights().GetText()));
  SetTransferMode(static_cast<TTransferMode>(Storage->ReadInteger("TransferMode", GetTransferMode())));
  SetResumeSupport(static_cast<TResumeSupport>(Storage->ReadInteger("ResumeSupport", GetResumeSupport())));
  SetResumeThreshold(Storage->ReadInt64("ResumeThreshold", GetResumeThreshold()));
  SetInvalidCharsReplacement(static_cast<wchar_t>(Storage->ReadInteger("ReplaceInvalidChars",
    static_cast<int>(GetInvalidCharsReplacement()))));
  SetLocalInvalidChars(Storage->ReadString("LocalInvalidChars", GetLocalInvalidChars()));
  SetCalculateSize(Storage->ReadBool("CalculateSize", GetCalculateSize()));
  if (Storage->ValueExists("IncludeFileMask"))
  {
    GetIncludeFileMask().SetMasks(Storage->ReadString("IncludeFileMask", GetIncludeFileMask().GetMasks()));
  }
  else if (Storage->ValueExists("ExcludeFileMask"))
  {
    UnicodeString ExcludeFileMask = Storage->ReadString("ExcludeFileMask", UnicodeString());
    if (!ExcludeFileMask.IsEmpty())
    {
      bool NegativeExclude = Storage->ReadBool("NegativeExclude", false);
      if (NegativeExclude)
      {
        GetIncludeFileMask().SetMasks(ExcludeFileMask);
      }
      // convert at least simple cases to new format
      else if (ExcludeFileMask.Pos(INCLUDE_EXCLUDE_FILE_MASKS_DELIMITER) == 0)
      {
        GetIncludeFileMask().SetMasks(UnicodeString(INCLUDE_EXCLUDE_FILE_MASKS_DELIMITER) + ExcludeFileMask);
      }
    }
  }
  SetTransferSkipList(nullptr);
  SetTransferResumeFile(L"");
  SetClearArchive(Storage->ReadBool("ClearArchive", GetClearArchive()));
  SetRemoveCtrlZ(Storage->ReadBool("RemoveCtrlZ", GetRemoveCtrlZ()));
  SetRemoveBOM(Storage->ReadBool("RemoveBOM", GetRemoveBOM()));
  SetCPSLimit(Storage->ReadInteger("CPSLimit", GetCPSLimit()));
  SetNewerOnly(Storage->ReadBool("NewerOnly", GetNewerOnly()));
}
예제 #13
0
//---------------------------------------------------------------------------
bool TFileMasks::MatchesMaskMask(const TMaskMask & MaskMask, const UnicodeString & Str)
{
  bool Result;
  if (MaskMask.Kind == TMaskMask::Any)
  {
    Result = true;
  }
  else if ((MaskMask.Kind == TMaskMask::NoExt) && (Str.Pos(L".") == 0))
  {
    Result = true;
  }
  else
  {
    Result = MaskMask.Mask->Matches(Str);
  }
  return Result;
}
예제 #14
0
//---------------------------------------------------------------------------
// TSrvResponse
//---------------------------------------------------------------------------
__fastcall TSrvResponse::TSrvResponse(UnicodeString ResponseText)
	: TStringList()
{
	if (ResponseText.IsEmpty()) throw ESrvResponseError(L"Server response is empty.");

	this->Text = ResponseText;
	try {
		this->StatusCode = StrToInt(this->Strings[0]);
	}
	catch (EConvertError& e) {
		throw ESrvResponseError(L"Cannot read status code. "+e.Message);
	}

	this->Delete(0); //Remove status code line

	for (int i = this->Count-1; i >= 0; i--) {
		UnicodeString line = this->Strings[i].Trim();
		int split = line.Pos(L":");
		if (split) {
			this->Strings[i] = line.SubString(1, split-1).Trim() \
			+ L":" \
			+ line.SubString(split+1, line.Length()-split).Trim();
		}
		else {
			this->Delete(i);
		}
	}

	this->NameValueSeparator = ':';

	if (this->StatusCode != 0) {
		if (this->StatusCode < 0) throw ESrvResponseError(L"Negative status code not allowed.");

		this->ErrorMessage = this->ReadString(TSrvResponseValID("ErrorMessage"), L"", true);
		if (this->ErrorMessage.IsEmpty()) this->ErrorMessage = L"Error #"
			+ IntToStr(this->StatusCode)
			+ L" (No error message provided).";
	}
	else { //Find URLs
		this->AvatarURL = this->Values[L"AvatarURL"];
		this->WatermarkURL = this->Values[L"WatermarkURL"];
    }
}
예제 #15
0
UnicodeString TCopyParamType::ChangeFileName(const UnicodeString & AFileName,
  TOperationSide Side, bool FirstLevel) const
{
  UnicodeString FileName = AFileName;
  if (FirstLevel)
  {
    FileName = MaskFileName(FileName, GetFileMask());
  }
  switch (GetFileNameCase())
  {
    case ncUpperCase:
      FileName = FileName.UpperCase();
      break;
    case ncLowerCase:
      FileName = FileName.LowerCase();
      break;
    case ncFirstUpperCase:
      FileName = FileName.SubString(1, 1).UpperCase() +
        FileName.SubString(2, FileName.Length() - 1).LowerCase();
      break;
    case ncLowerCaseShort:
      if ((FileName.Length() <= 12) && (FileName.Pos(L".") <= 9) &&
          (FileName == FileName.UpperCase()))
      {
        FileName = FileName.LowerCase();
      }
      break;
    case ncNoChange:
    default:
      /*nothing*/
      break;
  }
  if (Side == osRemote)
  {
    FileName = ValidLocalFileName(FileName);
  }
  else
  {
    FileName = RestoreChars(FileName);
  }
  return FileName;
}
예제 #16
0
//---------------------------------------------------------------------------
bool StartsText(const UnicodeString & ASubText, const UnicodeString & AText)
{
  return AText.Pos(ASubText) == 1;
}
예제 #17
0
bool StartsStr(const UnicodeString & SubStr, const UnicodeString & Str)
{
    return Str.Pos(SubStr) == 1;
}
예제 #18
0
intptr_t AnsiPos(const UnicodeString & Str, wchar_t Ch)
{
  intptr_t Result = Str.Pos(Ch);
  return Result;
}
예제 #19
0
intptr_t Pos(const UnicodeString & Str, const UnicodeString & Substr)
{
  intptr_t Result = Str.Pos(Substr.c_str());
  return Result;
}
예제 #20
0
bool StartsStr(UnicodeString SubStr, UnicodeString Str)
{
  return Str.Pos(SubStr) == 1;
}