ocean-tracking-network / glatos

9 stars 4 forks source link

vrl2csv bug fix for paths that contain spaces. #167

Closed mhpob closed 2 years ago

mhpob commented 2 years ago

Should close #137.

mhpob commented 2 years ago

Closing this to branch off dev

mhpob commented 2 years ago

To test:

Check that the VRL is converted if there are spaces in the file path

## Access internal VLR
myVRL <- system.file("extdata", "VR2W_109924_20110718_1.vrl",
                     package="glatos")

## Create tempdir with spaces in the file path
temp_dir <- tempdir()
test_dir <- file.path(temp_dir, 'test dir')
dir.create(test_dir)

## Copy internal VLR to tempir
file.copy(myVRL, test_dir)

## Check files
list.files(test_dir, full.names = T)

## Run vrl2csv
vrl2csv(list.files(test_dir, full.names = T, pattern = '*.vrl'),
        outDir = test_dir,
        vueExePath = 'C:/Program Files (x86)/VEMCO/VUE')

## Check that CSV was created
list.files(test_dir)
readLines(list.files(test_dir, full.names = T, pattern = '*.csv'), 10)

Check that a warning is shown if VRL is not converted

## Delete the CSV that was just made
file.remove(list.files(test_dir, full.names = T, pattern = '*.csv'))

## Corrupt the VRL
write(c('SOMEgibberish'), list.files(test_dir, full.names = T, pattern = 'vrl'))

## Try to import
vrl2csv(list.files(test_dir, full.names = T, pattern = '*.vrl'),
                outDir = test_dir,
                vueExePath = 'C:/Program Files (x86)/VEMCO/VUE')

# Delete tempdir
unlink(temp_dir, recursive = T)
mhpob commented 2 years ago

@chrisholbrook that was an error on my part. Changing that back to return and moving to after the warning will have it behave normally.