dts: Delete trailing slash

View source: R/utils.R

dtsR Documentation

Delete trailing slash

Description

This function cleans up a path string by removing the trailing slash. This is necessary on MS Windows, file.exists(fn) fails if "/" is on end of file name. Deleting the trailing slash is thus required on Windows and it is not harmful on other platforms.

Usage

dts(name)

Arguments

name

A path

Details

All usages of file.exists(fn) in R should be revised to be multi-platform safe by writing file.exists(dts(fn)).

This version also removes repeated adjacent slashes, so that "/tmp///paul//test/" becomes "/tmp/paul/test".

Value

Same path with trailing "/" removed.

Author(s)

Paul Johnson <pauljohn@ku.edu>


kutils documentation built on Sept. 17, 2023, 5:06 p.m.