Yehoshaphat Schellekens
Yehoshaphat Schellekens

Reputation: 2385

Assessing how large a file (How much RAM it will take) will be in R before loading it

I was wondering if there's some function that given a file name + path can asses how much RAM R will need to use it? i want to be able to know this info before I'm loading it.

Upvotes: 1

Views: 185

Answers (1)

user3747345
user3747345

Reputation: 408

You can use 'fstat' http://linux.die.net/man/2/fstat

It will report information about your file, such as actual filesize.

struct stat {
    dev_t     st_dev;     /* ID of device containing file */
    ino_t     st_ino;     /* inode number */
    mode_t    st_mode;    /* protection */
    nlink_t   st_nlink;   /* number of hard links */
    uid_t     st_uid;     /* user ID of owner */
    gid_t     st_gid;     /* group ID of owner */
    dev_t     st_rdev;    /* device ID (if special file) */
    off_t     st_size;    /* total size, in bytes */
    blksize_t st_blksize; /* blocksize for file system I/O */
    blkcnt_t  st_blocks;  /* number of 512B blocks allocated */
    time_t    st_atime;   /* time of last access */
    time_t    st_mtime;   /* time of last modification */
    time_t    st_ctime;   /* time of last status change */
};

Upvotes: 1

Related Questions