home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-04-13 | 1.5 KB | 78 lines | [TEXT/ttxt] |
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- expanded class FILE_TOOLS
-
- inherit ANY
- redefine same_files
- end;
-
- feature
-
- same_files(path1, path2: STRING): BOOLEAN is
- -- True if `path1' file exists and as the
- -- same contents as file `path2'.
- require else
- path1 /= Void;
- path2 /= Void;
- do
- if file_exists(path1) then
- if file_exists(path2) then
- std_fr1.connect_to(path1);
- if std_fr1.is_connected then
- std_fr2.connect_to(path2);
- if std_fr2.is_connected then
- Result := std_fr1.same_as(std_fr2);
- end;
- else
- std_fr1.disconnect;
- end;
- end;
- end;
- end;
-
- is_readable(path: STRING): BOOLEAN is
- -- True if `path' file exists and is a readable file.
- do
- std_fr1.connect_to(path);
- Result := std_fr1.is_connected;
- if Result then
- std_fr1.disconnect;
- end;
- end;
-
- is_empty(path: STRING): BOOLEAN is
- -- True if `path' file exists, is readable and is an
- -- empty file.
- do
- if file_exists(path) then
- std_fr1.connect_to(path);
- if std_fr1.is_connected then
- std_fr1.read_character;
- Result := std_fr1.end_of_input;
- std_fr1.disconnect;
- end;
- end;
- end;
-
- feature {NONE}
-
- std_fr1: STD_FILE_READ is
- once
- !!Result.make;
- end;
-
- std_fr2: STD_FILE_READ is
- once
- !!Result.make;
- end;
-
- feature {NONE}
-
- tmp_string: STRING is
- once
- !!Result.make(256);
- end;
-
- end -- FILE_TOOLS
-