stat

What are the semantics of 'stat' on a dirhandle in Perl?

On researching another question I noted that the stat function in Perl can take a dirhandle as its argument (instead of a filehandle or filename). However I can't find any examples of correct use of this - there are none in the Perl manual. Can anyone show an example of how to use it? ...

Get owner's access permissions using C++ and stat

How can I get the file owner's access permissions using stat from sys/stat.h using C++ in Kubuntu Linux? Currently, I get the type of file like this: struct stat results; stat(filename, &results); cout << "File type: "; if (S_ISDIR(results.st_mode)) cout << "Directory"; else if (S_ISREG(results.st_mode)) cout << "...

Static members in VB.NET

I used to write this: Private Sub Example() Static CachedPeople As List(Of MyApp.Person) If CachedPeople Is Nothing Then CachedPeople = New List(Of MyApp.Person) End If ...rest of code... End Sub But then wondered if I could reduce this to: Private Sub Example() Static CachedPeople As New List(Of MyApp.Person) ...rest of code... ...

Static field and Object reference not set to an instance of an object

I have a static field in a non static class. public class DBtools { public static string ConString ="XXXXXXXXX"; } This field is assigned to property in the code. SqlDataSource1.ConnectionString = DBtools.ConString; But after i run this app I'm getting a error Object reference not set to an instance of an object How come this...

List regular files only (without directory) problem

Hello, Do you know why a lot of file are not listed by this program, even if they are "regular"? #include <stdio.h> #include <sys/types.h> #include <sys/param.h> #include <sys/stat.h> #include <dirent.h> int main(void) { DIR *dh = opendir("./"); // directory handle struct dirent *file; // a 'directory entity' AKA file struct...

How does stat() work?

stattest.c: // compile: gcc -o stattest stattest.c #include <stdio.h> #include <sys/stat.h> int main(int argc, char *argv[]) { struct stat stats; stat(argv[1], &stats); printf("%lli\n", (long long)stats.st_dev); return 0; } Usage: stat -f "%r" /dev/disk0 => 234881024 (Value that I'm looking for.) ....

How can I compare mtimes returned by Perl's stat?

Hello. I found some sample scripts "stat" usage below. $source_mtime = (stat($source_file))[9]; $dest_file_mtime = (stat($dest_file))[9]; $script_mtime = (stat($this_file))[9]; if (-e $dest_xml_file) { if ($dest_file_mtime gt $source_mtime) // gt used { printf "No $this_file Scan Needed\n"; exit(0); } ...

Is there a faster alternative to Perl's stat?

I'm traversing an entire partition, stat()'ing each file and then checking the returned values for mtime, size and uid against hashed values. stat() however is far too slow in Perl and I'm wondering if there's any quicker alternatives I may be overlooking. ...

Check if a file is setuid root in Python

Hi there, I'm trying to check if a file has the setuid bit in Python. The stat doc mentions a S_ISUID function but it only works with os.chmod(), not to actually read the setuid bit. It also lists S_IMODE, but I have no idea how to interpret it. How can I easily check if a file as the setuid root bit set? ...

How can I get the high-res mtime for a symbolic link in Perl?

I want to reproduce the output of ls --full-time from a Perl script to avoid the overhead of calling ls several thousand times. I was hoping to use the stat function and grab all the information from there. However, the timestamp in the ls output uses the high-resolution clock so it includes the number of nanoseconds as well (according...

Inconsistency in modified/created/accessed time on mac

I'm having trouble using os.utime to correctly set the modification time on the mac (Mac OS X 10.6.2, running Python 2.6.1 from /usr/bin/python). It's not consistent with the touch utility, and it's not consistent with the properties displayed in the Finder's "get info" window. Consider the following command sequence. The 'created' and ...

How can I get the last modified time of a directory in Perl on Windows?

In Perl (on Windows) how do I determine the last modified time of a directory? Note: opendir my($dirHandle), "$path"; my $modtime = (stat($dirHandle))[9]; results in the following error: The dirfd function is unimplemented at scriptName.pl line lineNumber. ...

How to get details like PHP's stat() but using (raw) FTP (CURL)?

Hello all! I'm new here. I've got a question related to PHP, FTP and CURL. I need to emulate PHP's stat() with CURL FTP. I already know that it may take more than one command to do it. Here's what I've got so far (PHP/STAT ... FTP/CURL): dev ino mode ... LIST * nlink uid ... LIST * gid ... LIST * rdev size ... SIZE (or better still, ...

stat() function doesnt seem to be working in test PAM module

I'm trying to write a PAM module. The PAM module creates a directory on first log in. Very similar to the pam_mkhomedir. Here is the code. PAM_EXTERN int pam_sm_open_session (pam_handle_t *pamh, int flags, int argc, const char **argv) { int retval; const char *user; const struct passwd *pwd; struct stat St; ...

How to retrieve file times with nanosecond precision?

I've just discovered that the stat() call, and the corresponding struct stat, does not contain fields for the file times with precision greater than one second. For setting these times, there are a variety of {f,l}utime{n,}s() functions, but not for getting. How then does obtain these times with nanosecond precision, preferably using PO...

tar --files-from complains "Cannot stat: No such file or directory"

When I type " tar -cvf ~/changeset.tar --files-from ~/changeset.txt", It responds with this output: http://pastie.org/1071080. Here is the contents of ~/changeset.txt: http://pastie.org/1071084 . In other words, a bunch of relative paths. As a sanity check, $ ls admin/memberinformation.php admin/memberinformation.php Why can't tar find...

How do you determine the optimal disk IO block size on Win32?

On Posix systems, the st_blksize member of the stat structure contains the optimal block size for IO for a given file. It looks like the Win32 implementations of stat (_stat & _stat64) do not support this field. What is the Win32 equivalent way of determining the optimal IO block size for a given file or filesystem? ...

Determine user/group ownership for a directory

I have a perl script that will perform some operations on directories, and I only wait it to run on directories for which the current user(e.g. the user executing the script) has ownership. I've tried the following: ... my $user = getlogin(); opendir(HANDLE, $path) or die ("No such directory: $path"); foreach my $directory (readdir HAN...

man 2 stat - how to figure out if a file is a link

I have the below code only a part of it is shown here and I am checking if a the type of file. struct stat *buf /* just to show the type buf is*/ switch (buf.st_mode & S_IFMT) { case S_IFBLK: printf(" block device\n"); break; case S_IFCHR: printf(" character device\n"); break; case S_IFDIR:...