TurboPower B树文件管理器和Delphi XE2-有人做过吗? [英] TurboPower B-Tree Filer and Delphi XE2 - Anyone done it?

查看:79
本文介绍了TurboPower B树文件管理器和Delphi XE2-有人做过吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可能是地球上最后一个依靠B-Tree Filer的家伙,但是我从Delphi 2007跳到了XE2。

I might be the last guy on the planet relying on B-Tree Filer but I made the jump from Delphi 2007 to XE2.

在克服了所有的AnsiChar之后和PAnsiChar问题,代码现在在页面上显示零项的范围检查导致崩溃。

After getting over all the AnsiChar and PAnsiChar issues, the code now crashes with a Range Check with zero items on a page.

有人在Delphi XE2下成功运行B-Tree Filer吗?如果是这样,您会怎么做? :)

Is anyone successfully running B-Tree Filer under Delphi XE2? If so, how'd ya do it? :)

更新此处的范围检查错误:

Update Range check error here:

procedure IsamUnPack(var Page : IsamPage; KeyL : Word); 
var 
  I, K, S : Word; 
  P : Array [0..0] Of Byte absolute Page; {Real bounds [0..65535]} 
begin 
 K := KeyL + 9; 
 S := Pred (Page.ItemsOnPage) * K + 6; 
 if KeyL <> MaxKeyLen then begin 
    for I := Page.ItemsOnPage downto 2 do begin 
     Move(P[S], Page.ItemArray[I], K); // Range Check error in Warren P's suggestion 
     S := S - K;  
     end; 
 end; 
end; 

虽然Page.ItemsOnPage不应为零(范围检查错误在此处有效),但可能由数据对齐问题引起。将此代码添加到BTDEFINE.INC似乎可以解决问题……

While Page.ItemsOnPage should never be zero (the Range Check error is valid here) it may have been caused by data alignment issues. This code, added to BTDEFINE.INC seems to be doing the trick...

{$IFDEF VER230}
{$DEFINE UsingDelphi}
{$ENDIF}

{$IFDEF VER230} {Delphi XE2}
{$A-} {align data on byte boundaries}
{$B-} {short circuit boolean evaluation}
{$H+} {long string support}
{$I-} {suppress I/O checking}
{$J+} {writeable typed constants}
{$P-} {do not allow open string parameters}
{$Q-} {overflow checking off}
{$R-} {range checking off}
{$T-} {no type checked pointers with @}
{$V-} {no var string checking}
{$X+} {extended syntax on}
{$DEFINE Delphi2006}
{$DEFINE Delphi1Plus}
{$DEFINE Delphi2Plus}
{$DEFINE Delphi3Plus}
{$DEFINE Delphi4Plus}
{$DEFINE Delphi5Plus}
{$DEFINE Delphi6Plus}
{$DEFINE Delphi7Plus}
{$DEFINE Delphi2005Plus}
{$DEFINE Delphi2006Plus}
{$ENDIF}


推荐答案

我做了一个快速移植,目前,我基本上可以正常工作了,足以使随附的Delphi演示正常工作。当我忽略了DEMO CODE中的某些字符串-> ansistring更改时,我的第一次尝试失败了,这导致演示代码功能 PadCH 发生故障。在修复此问题之后,该演示和基础库似乎可以正常运行,至少是为了读取而已,但我尚未测试编写,修改和创建文件。演示中的上述文件是在较早的版本中创建的,因此至少是二进制读取兼容的。如果有很多错误,数据损坏问题等等,我不会感到惊讶,因此请不要在生产中使用此代码,否则,请您自担风险。

I did a quick port, and I currently have it basically working, well enough for the included Delphi demo to work. My first try failed when I overlooked some string -> ansistring changes in the DEMO CODE, which caused the demo code function PadCH to malfunction. After I fixed that, the demo, and underlying library appears functional, at least for reading, but I did not test writing, modifying, and creating files yet. The above file in the demo was created in an earlier version, so at least it's binary-read compatible. I wouldn't be surprised if there were lots of bugs, data corruption issues, and so on, so please do not use this code in production, or if you do, you do so at your own risk.

我的工作在这里:托管在Microsoft skydrive (4.3兆,ZIP)
(文件名tpbtreefiler_xe2_v2.zip)

My work is here: hosted at microsoft skydrive (4.3 megs, ZIP) (filename tpbtreefiler_xe2_v2.zip)

更新功能IsamUnpack

Update Function IsamUnpack is in ISAMWORK.INC.

Update2 。看来,OP现在发现添加一些ifdef-version-constant支持会导致{$为了使库正常工作,还需要R-}和一些需要打开的对齐标志。我可以建议在BTDEFINE.INC中采用以下不同的声明方式,即通过使用在下一个delphi版本中不会中断的比较来解决经典的Delphi每次更改Delphi编译器版本时都会中断的问题:

Update2 It appears that the OP has discovered now that adding some ifdef-version-constant support causes the {$R-} and some alignment flags to be switched on which are also required, for the library to work properly. May I suggest the following different way of declaring in BTDEFINE.INC, that gets around a classic Delphi "break every time we change Delphi compiler versions" by using a comparison that won't break on the next delphi release:

{$IF CompilerVersion > 20.0 } 
{ Keep working from Delphi 2009 UP}
{$DEFINE UsingDelphi}
{$A-} {align data on byte boundaries}
{$B-} {short circuit boolean evaluation}
{$H+} {long string support}
{$I-} {suppress I/O checking}
{$J+} {writeable typed constants}
{$P-} {do not allow open string parameters}
{$Q-} {overflow checking off}
{$R-} {range checking off}
{$T-} {no type checked pointers with @}
{$V-} {no var string checking}
{$X+} {extended syntax on}
{$DEFINE Delphi2006}
{$DEFINE Delphi1Plus}
{$DEFINE Delphi2Plus}
{$DEFINE Delphi3Plus}
{$DEFINE Delphi4Plus}
{$DEFINE Delphi5Plus}
{$DEFINE Delphi6Plus}
{$DEFINE Delphi7Plus}
{$DEFINE Delphi2005Plus}
{$DEFINE Delphi2006Plus}
{$ENDIF}

更新3 我怀疑代码中仍然存在移植问题,这可能会导致数据丢失和数据文件损坏。这是一个示例,其中记录数(在我的演示应用中应为50左右的数字)被报告为大于100万的数字,这显然是无效的。

Update 3 I suspect there are still porting issues in the code, that could cause data loss and data file corruption. Here's an example where the number of records (which should be a number in the range around 50 in my demo app) is being reported as a number > 1 million, which is clearly invalid.

这篇关于TurboPower B树文件管理器和Delphi XE2-有人做过吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆