Until recently it was simple to read all the SVN:Externals referenced in a subversion working copy by just reading some text files stored in the .svn subdirectory. With the change to a new on disk structure using mysql tables this is no longer that simple.
I want to update an internally used tool that used to read that list of externals to using the new structure. The Tool is written in Delphi 2007 so I would prefer some code written in Delphi.
There is Version Insight for RAD Studio on sourceforge which might contain some code to do the trick but I wonder if any body else has maybe already gone through the work of extracting the required parts from that project or has an alternative.
You can also do it programmatically, using the Subversion client DLLs. Here is a minimal example written in Delphi XE:
program svnext;
{$APPTYPE CONSOLE}
uses
SysUtils,
SvnClient;
procedure Main;
var
SvnClient: TSvnClient;
SvnItem: TSvnItem;
begin
// Subversion client DLL directory; here I simply use the .exe's directory
// (I copied the DLLs there manually.)
BaseDllDir := ExtractFilePath(ParamStr(0));
SvnClient := nil;
SvnItem := nil;
try
SvnClient := TSvnClient.Create;
SvnClient.Initialize;
SvnItem := TSvnItem.Create(SvnClient, nil, ParamStr(1));
Writeln(SvnItem.PropValues['svn:externals']);
finally
SvnItem.Free;
SvnClient.Free;
end;
end;
begin
try
Main;
except
on E: Exception do
begin
ExitCode := 1;
Writeln(Format('[%s] %s', [E.ClassName, E.Message]));
end;
end;
end.
You might have to tweak the code for Delphi 2007. It seems Version Insight has evolved in the meantime and lost (some of) the backward compatibility.
If you can call the svn executable, it is pretty easy to find all the externals stored in your repository :
svn propget -R svn:externals .
will return :
first/path/to/external - name_of_first_external http://first_repos/that/is/in/external
second/path/to/external - name_of_second_external http://second_repos/that/is/in/external
Like others said, call the SVN executable. You can integrate this with the Delphi Tools menu using this technique:
http://delphi.wikia.com/wiki/Adding_TortoiseSVN_to_the_Tools_menu
To add to that article, it's also VERY handy to have an "open folder here" entry that opens Windows Explorer for the folder of the file being edited. Here's the "tool properties" for that:
Title: Open Folder Here
Program: explorer.exe
Parameters: $PATH($EDNAME)
If you have this, then you've got all of TortoiseSVN at your fingertips.
Related
I just found that lockbox 3.6.0 should support Android. However when i look in my palette i see that the codec only supports win32 and win64.
How can i make it work for my android apps also?
Im using Delphi XE7 and have already followed the installation instructions supplied in the package. For a windows app it works just fine.
You have two options:
(1) Run-time
You can always create the components at run-time. There is an example on the website on how to do it, and I copy a fragment of this example below. Just replace the ShowMessage() functions with whatever is appropriate ...
procedure EncryptAStream( Plaintext, Ciphertext: TStream);
var
Codec1: TCodec;
CryptographicLibrary1: TCryptographicLibrary;
begin
ShowMessage( 'Demonstration of How to Encrypt a Stream with TurboPower LockBox 3.');
Codec1 := TCodec.Create( nil);
CryptographicLibrary1 := TCryptographicLibrary.Create( nil);
Codec1.CryptoLibrary := CryptographicLibrary1;
Codec1.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
Codec1.BlockCipherId := 'native.AES-256';
Codec1.ChainModeId := uTPLb_Constants.CBC_ProgId;
Codec1.Password := 'my utf-16le password';
// Codec1.Reset; Reset if you are continuing from a previous encryption operation.
Codec1.EncryptStream( Plaintext, Ciphertext);
// Codec1.Burn; Burn if you need to purge memory of sensitive data.
Ciphertext.Position := 0;
ShowMessageFmt(
'The ciphertext for AES-256 with CBC chaining'#13#10 +
' of plaintext ''banana'' (UTF-8 encoding),'#13#10 +
' and password ''my utf-16le password'' (UTF-16LE encoding),'#13#10 +
' prepended by 64 bit nonce, (being the IV),'#13#10 +
' and rendered for display in base64 is ...'#13#10 +
'%s', [Stream_to_Base64( Ciphertext)]);
Codec1.Free;
CryptographicLibrary1.Free;
end;
(2) Design-time
A little bit of tweaking is required to get the components onto the palette for Android. This will be done for you in the next version of TPLockbox 3 to be released, but for now, here is the procedure ...
Remove vcl, vclimg and dbrtl from the TPLB3 run-time requirements.
For the run-time package, add the Android target platform, and make it the active one. But of course, don't add this platform to the design-time package.
The binary product for the run-time should be named libTP_LockBox3_XE7.so, where XE7 is a place-marker for your compiler version.
Preface the declarations for the two components (TCodec and TCryptographicLibrary) with
[ComponentPlatformsAttribute( pidWin32 or pidWin64 or pidOSX32 or pidiOSSimulator or pidiOSDevice or pidAndroid)]
TCodec = class( TTPLb_BaseNonVisualComponent, ICryptographicLibraryWatcher,
{ etc. }
This is the key to the whole thing. The ComponentPlatformsAttribute attribute declares what platforms should the component be displayed for, on the palette. If not declared, I believe that the default is pidWin32 or pidWin64, but I cannot point to any official documentation to support this.
Recompile the run-time package. Remember that if your are compiling with MS-BUILD, on certain compiler versions, you need to save-all before you can successfully compile.
Go to the IDE Tools | Options and open the Library Path for the Android platform. Make sure that this path include the location of where you put the dcu files for the Android case. For example, on my installation it is ...
C:\Dev\TPLB\work-products\ephemeral\dcu\XE6\Android
You should physically check this directory. It should have a file named TPLB3.AES.dcu and another named TPLB3.AES.so for example.
Recompile and re-install the design-time package
Open your mobile project. Slap design-time components for TCodec and TCryptographicLibrary on your Android forms. Proceed as you would for a windows application.
I'm having a hard time to make my code work. I want to connect to a database with my application in Delphi 7, but if I change the folder of the application, for example, if I install in another computer, my datamodule stops working. The error is:
Raised exception class EdatabaseError with message "Missing Drivername propriety"
My actual code is:
procedure TDataModule1.DataModuleCreate(Sender: TObject);
var
conexao : TSQLConnection;
begin
with SQLConnection1 do
begin
ConnectionName := 'SKY';
DriverName := 'Interbase';
LibraryName := 'dbexpint.dll';
VendorLib := 'gds32.dll';
GetDriverFunc := 'getSQLDriverINTERBASE';
LoadParamsOnConnect := true;
LoginPrompt := False;
Params.Add('Database='+ExtractFilePath(Application.ExeName)+'\Banco\FLY_SKY_DESK.FDB');
Params.Add('User_Name=SYSDBA');
params.Add('Password=masterkey');
Params.Add('SQLDialect=3');
Open;
end;
SQLConnection1.Connected:=true;
end;
I want to connect to the database using my .exe, on any path or install location.
If you are running Windows 7 or Vista, and install your app into the "\Program files" (either one) directory, this will not work due to folder virtualization within UAC.
You should NOT attempt to place the database within the same directory that the program is running from. You will get away with it on XP and earlier. From then on, it's a no-no.
This may not be your problem, but it definitely IS a problem.
I faced a similar problem when I tried to write code which would open a Firebird database from a thread. The code looks like you are using the dbExpress TSQLConnection; it's much easier if you use the IB components, specifically TIBDatabase. Then your code becomes something like the following
var
ibdb: TIBDatabase;
qDefaults: TIBQuery;
trans: TIBTransaction;
begin
ibdb:= TIBDatabase.Create (nil);
ibdb.databasename:= ExtractFilePath(Application.ExeName)+'\Banco\FLY_SKY_DESK.FDB')
ibdb.loginprompt:= false;
ibdb.params.add ('password=masterkey');
ibdb.params.add ('user_name=sysdba');
ibdb.sqldialect:= 3;
ibdb.connected:= true;
trans:= TIBTransaction.create (nil);
trans.defaultdatabase:= ibdb;
qDefaults:= TIBQuery.create (nil);
qDefaults.database:= ibdb;
qDefaults.transaction:= trans;
qDefaults.sql.Add ('select * from defaults');
qDefaults.active:= true;
...
You are most likely missing the DLLs required on the target computer. You'll need to figure out which DLLs should be included with the client application and install them on the target computer. Often, simply placing the required DLLs in the same folder as the EXE will work.
I can't figure out quite what you're using since you reference Interbase and dbExpress and Firebird, but your target computer probably doesn't have the needed drivers.
You need to deploy:
dbxconnections.ini
dbxdrivers.ini
dbxfb.dll
fbclient.dll
midas.dll {in case you used ClientDatasSet and you didn't include MidasLib into uses clause}
after deploy all those files along with your Exe than you need to update registry entry to point to locations of dbxconnections.ini and dbxdrivers.ini my version is delphi 10.3 so the registry entry are located in
HKEY_CURRENT_USER > Software > Embarcadero > BDS > 20.0 > DBExpress
Connection Registry File value is the path to dbxconnections.ini
Driver Registry File value is the path to dbxdrivers.ini
I just downloaded the dbExpress Driver for Firebird by Chee-Yang Chau from this google code site.
I loaded the Delphi 2010 demo projects and tried running it and immediatedly got a could not load dll error:
INI File
[Installed Drivers]
FirebirdConnection=1
[FirebirdConnection]
;DriverUnit=DBXInterBase
;DriverPackageLoader=TDBXDynalinkDriverLoader,DbxCommonDriver120.bpl
;DriverAssemblyLoader=Borland.Data.TDBXDynalinkDriverLoader,Borland.Data.DbxCommonDriver,Version=12.0.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b
;MetaDataPackageLoader=TDBXInterbaseMetaDataCommandFactory,DbxInterBaseDriver120.bpl
;MetaDataAssemblyLoader=Borland.Data.TDBXInterbaseMetaDataCommandFactory,Borland.Data.DbxInterBaseDriver,Version=12.0.0.0,Culture=neutral,PublicKeyToken=91d62ebb5b0d1b1b
GetDriverFunc=getSQLDriverFIREBIRD
LibraryName=dbxfb4d14.dll
VendorLib=C:\Program Files\Firebird\Firebird_1_5\bin\fbclient.dll
BlobSize=-1
CommitRetain=False
Database=database.gdb
ErrorResourceFile=
LocaleCode=0000
Password=masterkey
RoleName=RoleName
ServerCharSet=
SQLDialect=3
Interbase TransIsolation=ReadCommited
User_Name=sysdba
WaitOnLocks=True
Trim Char=False
Delphi Code
procedure TMainForm.Button1Click(Sender: TObject);
var C: TSQLConnection;
begin
C := TSQLConnection.Create(Self);
try
C.DriverName := 'FirebirdConnection';
// C.LibraryName := 'dbxufb40.dll';
// C.VendorLib := 'C:\Program Files\Firebird\Firebird_1_5\bin\fbclient.dll';
// C.GetDriverFunc := 'getSQLDriverFIREBIRD';
C.Params.Add('User_Name=SYSDBA');
C.Params.Add('Password=masterkey');
C.Params.Add('Database=localhost:%ProgramFiles%\Firebird\Firebird_1_5\examples\employee.fdb');
C.Open;
if C.Connected then
ShowMessage('Connection is active')
finally
C.Free;
end;
end;
I noticed that the library name dbxfb4d14.dll in the ini file did not match the actual dll name dbxfb4d15.dll so I modified the ini file so it would match the name of the dll.
Now I get an error saying the dbxfb4d15.dll cannot be found.
What am I doing wrong?
You do need the d14 version for Delphi 2010. The d15 version is for XE. Not sure why there is only the d15 version in the zip.
The DLL is not located on your DLL search path. Once you get hold of the right DLL then you need to make sure it's on the path.
Having browsed around this component I'm not convinced it's terribly polished. If you can afford it, the Devart drivers come highly recommended.
I am going through most of my applications and porting them to D2009 and I have one application that makes use of dynamic packages. For the life of me I cannot get my host application to recognize classes registered in a package. I traced through and the initialization section in the package being loaded was called and RegisterClasses was called but when I do a GetClass() call the classes are not available. Is there someone out there who can enlighten me as to what might be going on? I have researched and looked to see if there are any issues with the D2009 release and dynamic packages and so far I have found nothing. I'm beginning to wonder if I have a corrupted installation of Delphi or some other problem.
TIA
If you are using a 3rd party memory manager then make sure it is proven to work with D2009 (actually 2007 and up).
With FastMM (which is the default MM since 2007) you would have to set the UseRuntimePackages define in FastMM4Options.inc
make sure that the following steps are done:
Create a new package in Delphi;
Insert a form in this package;
Insert a "inicialization" section in the form and uses the RegisterClass method. (registerClass(TForm1)); Don't forget the "T".
Save and compile the package;
Close all;
Copy the .bpl file (c:\Users\Public\Documents\RAD Studio\5.0\Bpl) to the application folder;
Create a new aplication in Delphi;
Go in Project > Options > Packages, and check the box "Build with runtime packages";
Leave only "vcl;rtl" in the text field and click OK button;
Insert a button;
In the source of the button, insert the code:
procedure TForm1.Button1Click(Sender: TObject);
var
PackageModule: HModule;
AClass: TPersistentClass;
begin
PackageModule := LoadPackage('Package1.bpl');
if PackageModule <> 0 then
begin
AClass := GetClass('TForm2');
if AClass <> nil then
with TComponentClass(AClass).Create(Application)
as TCustomForm do
begin
ShowModal;
Free;
end;
UnloadPackage(PackageModule);
end;
end;
Compile the application. =)
That is, delete all files matching pattern within a given directory
Example, Delete all *.jpg files within DirectoryName
procedure TForm1.Button1Click(Sender: TObject);
begin
DeleteFiles(ExtractFilePath(ParamStr(0)),'*.jpg');
end;
procedure DeleteFiles(APath, AFileSpec: string);
var
lSearchRec:TSearchRec;
lPath:string;
begin
lPath := IncludeTrailingPathDelimiter(APath);
if FindFirst(lPath+AFileSpec,faAnyFile,lSearchRec) = 0 then
begin
try
repeat
SysUtils.DeleteFile(lPath+lSearchRec.Name);
until SysUtils.FindNext(lSearchRec) <> 0;
finally
SysUtils.FindClose(lSearchRec); // Free resources on successful find
end;
end;
end;
In more recent versions of Delphi, you would probably use the classes in System.IOUtils, which are essentially wrapping FindFirst, FindNext etc:
procedure DeleteFilesMatchingPattern(const Directory, Pattern: string);
var FileName: string;
begin
for FileName in TDirectory.GetFiles(Directory, Pattern) do TFile.Delete(FileName);
end;
You can use the SHFileOperation function. The nice thing about using SHFileOperation is you have the option of deleting the files to the recycle bin and you get the normal API animations so the user will know what is going on. The downside is the delete will take a little longer than Jeff's code.
There are several wrappers out there. I use this free wrapper from BP Software. The entire wrapper file is only 220 lines and is easy to read and use. I don't install this as a component. I have found it easier to add this unit to my project and just Create and free the object as needed.
Update: The download link for the BP Software site is no longer valid. There is an older version on the Embarcadero website.
TSHFileOp (1.3.5.1) (3 KB) May
31, 2006 TComponent that is a wrapper
for the SHFileOperation API to copy,
move, rename, or delete (with
recycle-bin support) a file system
object.
The file name parameter for SHFileOperation supports MS DOS style wildcards. So you can use the component like this:
FileOps := TSHFileOp.Create(self);
FileOps.FileList.Add(DirectoryName + '\*.jpg');
FileOps.HWNDHandle := self.Handle;
FileOps.Action := faDelete;
FileOps.SHOptions :=
[ofAllowUndo, ofNoConfirmation, ofFilesOnly, ofSimpleProgress];
FileOps.Execute;
I usually show the "Are you sure" message myself so I always pass the ofNoConfirmation flag so Windows does not ask again.
If you don't want to delete every jpg file or you need to delete from multiple directories you can add full file names or different paths with wild cards to the FileList string list before calling execute.
Here is the MSDN Page for SHFileOperation
Note that SHFileOperation has been replaced by IFileOperation starting with Windows Vista. I have continued to use SHFileOperation on Windows Vista without any problems.