Browse Source

* PChar -> PAnsiChar

Michaël Van Canneyt 2 years ago
parent
commit
6f5c356ae5
1 changed files with 13 additions and 9 deletions
  1. 13 9
      utils/pas2js/dirwatch.pp

+ 13 - 9
utils/pas2js/dirwatch.pp

@@ -400,24 +400,28 @@ Const
   Events = IN_MODIFY or IN_ATTRIB or IN_CREATE or IN_DELETE;
   Events = IN_MODIFY or IN_ATTRIB or IN_CREATE or IN_DELETE;
 
 
 Var
 Var
+  ds : ansistring {$IF SIZEOF(CHAR)=1} absolute d {$Endif};
   fd, wd,fnl,len : cint;
   fd, wd,fnl,len : cint;
   fds : tfdset;
   fds : tfdset;
   e : ^inotify_event;
   e : ^inotify_event;
   buf : Array[0..1023*4] of Byte; // 4K Buffer
   buf : Array[0..1023*4] of Byte; // 4K Buffer
-  fn : string;
-  p : pchar;
+  fn : ansistring;
+  p : pansichar;
 
 
 begin
 begin
+  {$IF SIZEOF(CHAR)=2} 
+  ds:=UTF8Encode(d);
+  {$Endif};
   fd:=inotify_init;
   fd:=inotify_init;
   try
   try
-    wd:=inotify_add_watch(fd,pchar(d),Events);
+    wd:=inotify_add_watch(fd,pansichar(ds),Events);
     fpFD_Zero(fds);
     fpFD_Zero(fds);
     fpFD_SET(fd,fds);
     fpFD_SET(fd,fds);
     While (fpSelect(fd+1,@fds,nil,nil,nil)>=0) do
     While (fpSelect(fd+1,@fds,nil,nil,nil)>=0) do
       begin
       begin
       len:=fpRead(fd,buf,sizeof(buf));
       len:=fpRead(fd,buf,sizeof(buf));
       e:=@buf;
       e:=@buf;
-      While ((pchar(e)-@buf)<len) do
+      While ((pansichar(e)-@buf)<len) do
         begin
         begin
         fnl:=e^.len;
         fnl:=e^.len;
         if (fnl>0) then
         if (fnl>0) then
@@ -459,7 +463,7 @@ Const
 Var
 Var
   WD,I,NEvents : Integer;
   WD,I,NEvents : Integer;
   E : TFileEvent;
   E : TFileEvent;
-  BD,FN : String;
+  BD,FN : AnsiString;
 
 
 begin
 begin
   BD:=BaseDir;
   BD:=BaseDir;
@@ -472,7 +476,7 @@ begin
     for E in FWatches[i].Events do
     for E in FWatches[i].Events do
       NEvents:=NEvents OR NativeEvents[E];
       NEvents:=NEvents OR NativeEvents[E];
     FN:=BD+FWatches[i].Name;
     FN:=BD+FWatches[i].Name;
-    wd:=inotify_add_watch(FINotifyFD,PChar(FN),NEvents);
+    wd:=inotify_add_watch(FINotifyFD,PAnsiChar(FN),NEvents);
     end;
     end;
 end;
 end;
 
 
@@ -511,8 +515,8 @@ Var
   fnl,len : cint;
   fnl,len : cint;
   e : ^inotify_event;
   e : ^inotify_event;
   buf : Array[0..1023*4] of Byte; // 4K Buffer
   buf : Array[0..1023*4] of Byte; // 4K Buffer
-  fn : string;
-  p : pchar;
+  fn : ansistring;
+  p : pansichar;
   fds : tfdset;
   fds : tfdset;
   Timeout : ttimeval;
   Timeout : ttimeval;
 
 
@@ -525,7 +529,7 @@ begin
     exit;
     exit;
   len:=fpRead(FINotifyFD,buf,sizeof(buf));
   len:=fpRead(FINotifyFD,buf,sizeof(buf));
   e:=@buf;
   e:=@buf;
-  While ((pchar(e)-@buf)<len) do
+  While ((pansichar(e)-@buf)<len) do
     begin
     begin
     fnl:=e^.len;
     fnl:=e^.len;
     if (fnl>0) then
     if (fnl>0) then