Browse Source

* LFN support in streams

pierre 25 years ago
parent
commit
7c29d75493
4 changed files with 136 additions and 34 deletions
  1. 8 5
      ide/text/fpdesk.pas
  2. 27 7
      ide/text/weditor.pas
  3. 53 19
      ide/text/wutils.pas
  4. 48 3
      rtl/go32v2/objinc.inc

+ 8 - 5
ide/text/fpdesk.pas

@@ -529,7 +529,7 @@ var OK,VOK: boolean;
     VM : TVideoMode;
 begin
   PushStatus('Reading desktop file...');
-  New(F, LoadFile(GetShortName(DesktopPath)));
+  New(F, LoadFile(DesktopPath));
 
   OK:=false;
 
@@ -569,7 +569,7 @@ var OK: boolean;
 begin
   TempPath:=DirOf(DesktopPath)+DesktopTempName;
   PushStatus('Writing desktop file...');
-  New(F, CreateFile(GetShortName(TempPath)));
+  New(F, CreateFile(TempPath));
 
   if Assigned(Clipboard) then
     if (DesktopFileFlags and dfClipboardContent)<>0 then
@@ -618,7 +618,7 @@ begin
   WriteSymbolsFile:=false;
   If not assigned(Modules) then
     exit;
-  New(F, CreateFile(GetShortName(FileName)));
+  New(F, CreateFile(FileName));
   OK:=Assigned(F);
   if OK and ((DesktopFileFlags and dfSymbolInformation)<>0) then
     OK:=OK and WriteSymbols(F);
@@ -635,7 +635,7 @@ begin
   { Don't read again !! }
   If assigned(Modules) then
     exit;
-  New(F, LoadFile(GetShortName(FileName)));
+  New(F, LoadFile(FileName));
   OK:=Assigned(F);
   if OK and ((DesktopFileFlags and dfSymbolInformation)<>0) then
       OK:=OK and ReadSymbols(F);
@@ -647,7 +647,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.23  2000-03-13 20:36:52  pierre
+  Revision 1.24  2000-03-20 19:19:46  pierre
+   * LFN support in streams
+
+  Revision 1.23  2000/03/13 20:36:52  pierre
    * Breakpoints saved and loaded before sources
 
   Revision 1.22  2000/02/07 12:03:48  pierre

+ 27 - 7
ide/text/weditor.pas

@@ -95,6 +95,7 @@ const
       edReadBlock     = 15;
       edFileOnDiskChanged = 16;
       edChangedOnloading = 17;
+      edSaveError     = 18;
 
       ffmOptions      = $0007; ffsOptions     = 0;
       ffmDirection    = $0008; ffsDirection   = 3;
@@ -269,6 +270,7 @@ type
       TabSize    : integer;
       HighlightRow: sw_integer;
       DebuggerRow: sw_integer;
+      ChangedLine : sw_integer;
       UndoList    : PEditorActionCollection;
       RedoList    : PEditorActionCollection;
       CompleteState: TCompleteState;
@@ -348,7 +350,6 @@ type
       LastSyntaxedLine : sw_integer;
       SyntaxComplete : boolean;
 {$endif TEST_PARTIAL_SYNTAX}
-      ChangedLine : sw_integer;
       ErrorMessage: PString;
       Bookmarks   : array[0..9] of TEditorBookmark;
       LockFlag    : integer;
@@ -5092,7 +5093,7 @@ function TFileEditor.LoadFile: boolean;
 var S: PBufStream;
     OK: boolean;
 begin
-  New(S, Init(GetShortName(FileName),stOpenRead,EditorTextBufSize));
+  New(S, Init(FileName,stOpenRead,EditorTextBufSize));
   OK:=Assigned(S);
 {$ifdef TEST_PARTIAL_SYNTAX}
   SyntaxComplete:=false;
@@ -5125,7 +5126,7 @@ begin
         end;
     end;
 {$I-}
-  if IsFlagSet(efBackupFiles) then
+  if IsFlagSet(efBackupFiles) and ExistsFile(FileName) then
   begin
      BAKName:=DirAndNameOf(FileName)+'.bak';
      Assign(f,BAKName);
@@ -5137,12 +5138,25 @@ begin
   end;
 {$I+}
   New(S, Init(FileName,stCreate,EditorTextBufSize));
-  OK:=Assigned(S);
+  OK:=Assigned(S) and (S^.Status=stOK);
   if OK then OK:=SaveToStream(S);
   if Assigned(S) then Dispose(S, Done);
-  if OK then SetModified(false);
+  if OK then
+    SetModified(false)
+  { Restore the original }
+  else if IsFlagSet(efBackupFiles) and ExistsFile(BakName) then
+    begin
+{$I-}
+     Assign(f,BakName);
+     Rename(F,FileName);
+     EatIO;
+{$I+}
+    end;
   { don't forget to update the OnDiskLoadTime value }
-  OnDiskLoadTime:=GetFileTime(FileName);
+  if OK then
+    OnDiskLoadTime:=GetFileTime(FileName);
+  if not OK then
+    EditorDialog(edSaveError,@FileName);
   SaveFile:=OK;
 end;
 
@@ -5478,6 +5492,9 @@ begin
    @Info, mfInsertInApp+ mfError + mfOkButton);
     edWriteError:
       StdEditorDialog := MessageBox('Error writing file %s.',
+   @Info, mfInsertInApp+ mfError + mfOkButton);
+    edSaveError:
+      StdEditorDialog := MessageBox('Error saving file %s.',
    @Info, mfInsertInApp+ mfError + mfOkButton);
     edCreateError:
       StdEditorDialog := MessageBox('Error creating file %s.',
@@ -5616,7 +5633,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.83  2000-03-14 13:38:03  pierre
+  Revision 1.84  2000-03-20 19:19:44  pierre
+   * LFN support in streams
+
+  Revision 1.83  2000/03/14 13:38:03  pierre
    * max number of line changed and warning added
 
   Revision 1.82  2000/03/02 22:33:36  pierre

+ 53 - 19
ide/text/wutils.pas

@@ -104,6 +104,7 @@ function DirAndNameOf(const S: string): string;
 function GetFileTime(const FileName: string): longint;
 { copied from compiler global unit }
 function GetShortName(const n:string):string;
+function GetLongName(const n:string):string;
 
 function EatIO: integer;
 
@@ -374,31 +375,61 @@ end;
 
 function GetShortName(const n:string):string;
 {$ifdef win32}
-      var
-        hs,hs2 : string;
-        i : longint;
+var
+  hs,hs2 : string;
+  i : longint;
 {$endif}
 {$ifdef go32v2}
-      var
-        hs : string;
+var
+  hs : string;
 {$endif}
-      begin
-        GetShortName:=n;
+begin
+  GetShortName:=n;
 {$ifdef win32}
-        hs:=n+#0;
-        i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
-        if (i>0) and (i<=high(hs2)) then
-          begin
-            hs2[0]:=chr(strlen(@hs2[1]));
-            GetShortName:=hs2;
-          end;
+  hs:=n+#0;
+  i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
+  if (i>0) and (i<=high(hs2)) then
+    begin
+      hs2[0]:=chr(strlen(@hs2[1]));
+      GetShortName:=hs2;
+    end;
+{$endif}
+{$ifdef go32v2}
+  hs:=n;
+  if Dos.GetShortName(hs) then
+   GetShortName:=hs;
+{$endif}
+end;
+
+function GetLongName(const n:string):string;
+{$ifdef win32}
+var
+  hs : string;
+  hs2 : Array [0..255] of char;
+  i : longint;
+  j : pchar;
 {$endif}
 {$ifdef go32v2}
-        hs:=n;
-        if Dos.GetShortName(hs) then
-         GetShortName:=hs;
+var
+  hs : string;
 {$endif}
-      end;
+begin
+  GetLongName:=n;
+{$ifdef win32}
+  hs:=n+#0;
+  i:=Windows.GetFullPathName(@hs[1],256,hs2,j);
+  if (i>0) and (i<=255) then
+    begin
+      hs:=strpas(hs2);
+      GetLongName:=hs;
+    end;
+{$endif}
+{$ifdef go32v2}
+  hs:=n;
+  if Dos.GetLongName(hs) then
+   GetLongName:=hs;
+{$endif}
+end;
 
 
 function EatIO: integer;
@@ -628,7 +659,10 @@ end;
 END.
 {
   $Log$
-  Revision 1.16  2000-03-14 13:36:12  pierre
+  Revision 1.17  2000-03-20 19:19:45  pierre
+   * LFN support in streams
+
+  Revision 1.16  2000/03/14 13:36:12  pierre
    * error for unexistant file in GetFileTime fixed
 
   Revision 1.15  2000/02/07 11:45:11  pierre

+ 48 - 3
rtl/go32v2/objinc.inc

@@ -43,7 +43,49 @@ BEGIN
          { get linear address from system unit }
          regs.realedx:=tb mod 16;
          regs.realds:=tb div 16;
-         regs.realeax := Mode;
+         if LFNSupport then
+           begin
+             if (mode = stCreate) then
+               begin
+                 regs.realeax := $716C;
+                 regs.realesi:=tb mod 16;
+                 regs.realebx:=$2002;
+                 regs.realecx:=$20;
+                 regs.realedi:=0;
+                 regs.realedx:=$12;
+               end
+             else if (mode = stOpenRead) then
+               begin
+                 regs.realeax := $716C;
+                 regs.realesi:=tb mod 16;
+                 regs.realebx:=$2000;
+                 regs.realecx:=$20;
+                 regs.realedi:=0;
+                 regs.realedx:=$1;
+               end
+             else if (mode = stOpenWrite) then
+               begin
+                 regs.realeax := $716C;
+                 regs.realesi:=tb mod 16;
+                 regs.realebx:=$2001;
+                 regs.realecx:=$20;
+                 regs.realedi:=0;
+                 regs.realedx:=$11;
+               end
+             else if (mode = stOpen) then
+               begin
+                 regs.realeax := $716C;
+                 regs.realesi:=tb mod 16;
+                 regs.realebx:=$2002;
+                 regs.realecx:=$20;
+                 regs.realedi:=0;
+                 regs.realedx:=$11;
+               end
+             else
+               regs.realeax := Mode;
+           end
+         else
+           regs.realeax := Mode;
          regs.realecx:=0;
          sysrealintr($21,regs);
          if (regs.realflags and 1) <> 0 then
@@ -131,7 +173,10 @@ END;
 
 {
   $Log$
-  Revision 1.4  2000-02-09 16:59:29  peter
+  Revision 1.5  2000-03-20 19:19:44  pierre
+   * LFN support in streams
+
+  Revision 1.4  2000/02/09 16:59:29  peter
     * truncated log
 
   Revision 1.3  2000/01/07 16:41:32  daniel
@@ -140,4 +185,4 @@ END;
   Revision 1.2  2000/01/07 16:32:23  daniel
     * copyright 2000 added
 
-}
+}