-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor file type check (lazy and only 1024 bytes) (#30)
* Add new binary check * Add new file type type and use * Simplify Filec.t * Fix: use with to make sure it gets closed
- Loading branch information
1 parent
7798895
commit 9c07624
Showing
6 changed files
with
60 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
(** File contents as an array of lines, where each line is wrapped into a | ||
document (for rendering efficiency) *) | ||
type t = | ||
type t = { | ||
lines : Pretty.Doc.t array; | ||
offset : int; | ||
} | ||
|
||
type file_type = | ||
| Binary | ||
| Text of { | ||
lines : Pretty.Doc.t array; | ||
offset : int; | ||
} | ||
| Text | ||
|
||
(** Reads file contents using 'bat' to have pretty syntax highlighting **) | ||
val read : string -> t | ||
|
||
(** Returns offset based on file type of contents **) | ||
val offset : t -> int | ||
|
||
(** Returns the len of file contents **) | ||
val length : t -> int | ||
|
||
(** Returns the lines of file contents **) | ||
val lines : t -> Pretty.Doc.t array | ||
(** Returns file_type based on the first 1024 bytes of the file **) | ||
val type_of_path : string -> file_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters