I guess I might as well comment - everyone else and his dog is doing so. A collegue said "A sad, sad day for FOSS". I know what he means, but actually I disagree. Take-overs and mergers will always happen.
It is occasions like this that demonstrate the power of FOSS. FOSS gives us choice, and we can choose to stay with MySQL or migrate to PostgreSQL, which all the smart people were using anyway. IMHO, technically PostgreSQL knocks MySQL into a cocked hat, and the Oracle takeover of MySQL could give PostgreSQL the increase in popularity it deserves. Other databases are available.
Sun blew hot and cold on FOSS anyway, I could never figure out what their policy was. Java probably has too much momentum of its own for Oracle to screw it up, although if anyone can.... Never underestimate the ability of corporates to kill things off by hubris (I used to work for Computer Associates).
There will always be other languages, other databases, other operating systems.
Other hardware?
Back in the 1980s a collegue (Haydn Moston - are you still around?) told me that CISC (Complex Instruction Set Computer) chips could never last beyond 2000, and RISC (Reduced Instruction Set Computer) chips were the only way to go. The i386 familiy is CISC, and Sun Sparc is the most well-known RISC.
Intel are running out of steam and having to use multi-core, ten years out was actually not bad Haydn. I'm not sure that the switch to multi-core is connected specifically with CISC, but the possible loss of RISC machines is my biggest worry with the Oracle takeover. The number of mainstream instruction sets out there is disapointingly small. How I hate monocultures.
Friday, January 29, 2010
Thursday, January 07, 2010
File notification events on Windows
One of my most popular posts is example code for Inotify on Linux. I have also been asked for similar code for Windows, so yer tis:
There are two different interfaces available on Win32, I prefer ReadDirectoryChangesW because it is easier to control:
There are two different interfaces available on Win32, I prefer ReadDirectoryChangesW because it is easier to control:
// ------------------------------------------------------------------
// Clive Darke QA Training
// ReadDirectoryChangesW example
// ------------------------------------------------------------------
#define _WIN32_WINNT 0x0400 // <<<<<<<<>
#include <iostream>
#include <windows.h>
void DisplayLastError( LPSTR lpszText );
// ------------------------------------------------------------------
int main ( int argc, char *argv[] )
{
HANDLE hDir;
DWORD dwReturned;
BOOL bResult;
FILE_NOTIFY_INFORMATION *pNotify;
if ( argc < 2 )
{
cerr << "You must supply a directory name" << endl;
return 1;
}
// Note FILE_FLAG_BACKUP_SEMANTICS, which is the strange
// attribute required to get a handle to a directory.
hDir = CreateFile (
argv[1], // pointer to the file name
FILE_LIST_DIRECTORY, // access (read-write) mode
FILE_SHARE_READ|FILE_SHARE_DELETE, // share mode
NULL, // security descriptor
OPEN_EXISTING, // how to create
FILE_FLAG_BACKUP_SEMANTICS, // file attributes
NULL // file with attributes to copy
);
char Buffer[MAX_PATH] = {0};
while (TRUE )
{
char szAction[42];
char szFilename[MAX_PATH];
bResult = ReadDirectoryChangesW (hDir, &Buffer, sizeof(Buffer),
TRUE, FILE_NOTIFY_CHANGE_FILE_NAME, &dwReturned, NULL, NULL);
if ( !bResult )
break;
pNotify = (FILE_NOTIFY_INFORMATION *) Buffer;
switch (pNotify->Action)
{
case FILE_ACTION_ADDED : {
strcpy (szAction, "added");
break;
case FILE_ACTION_REMOVED :
strcpy (szAction, "removed");
break;
case FILE_ACTION_MODIFIED :
strcpy (szAction, "modified");
break;
case FILE_ACTION_RENAMED_OLD_NAME :
strcpy (szAction, "renamed");
break;
case FILE_ACTION_RENAMED_NEW_NAME :
strcpy (szAction, "renamed");
break;
default:
strcpy (szAction, "Unknown action");
}
wcstombs( szFilename, pNotify->FileName, MAX_PATH);
cout << "File " << dwerror =" GetLastError();" lpmessagebuffer =" NULL;">
Subscribe to:
Posts (Atom)