Skip to content

Commit

Permalink
read_BIN2R():
Browse files Browse the repository at this point in the history
+ ad close connection
  • Loading branch information
RLumSK committed Apr 29, 2024
1 parent 2055ba2 commit a519eaf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/read_BIN2R.R
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ read_BIN2R <- function(
# Short file parsing to get number of records -------------------------------------------------
#open connection
con <- file(file, "rb")
on.exit(close(con))

##get information about file size
file.size <- file.info(file)
Expand All @@ -315,14 +316,14 @@ read_BIN2R <- function(
temp.ID <- 0

##start for BIN-file check up
while(length(temp.VERSION<-readBin(con, what="raw", 1, size=1, endian="little"))>0) {
while(length(temp.VERSION <- readBin(con, what="raw", 1, size=1, endian="little"))>0) {
##force version number
if(!is.null(forced.VersionNumber)){
temp.VERSION <- as.raw(forced.VersionNumber)
}

##stop input if wrong VERSION
if((temp.VERSION%in%VERSION.supported) == FALSE){
if(!all((temp.VERSION %in% VERSION.supported))){
if(temp.ID > 0){
if(is.null(n.records)){
warning(paste0("[read_BIN2R()] BIN-file appears to be corrupt. Import limited to the first ", temp.ID," record(s)."),
Expand Down

0 comments on commit a519eaf

Please sign in to comment.