A little while back, I bought one of those pressed-wood laminate entertainment-center-in-a-box things from my local Wal*Mart. After lugging the giant box inside and putting half of it together, I was disappointed (to say the least) when I found out that they neglected to include a bag of those custom Twist-Lock® fasteners things. It was quite a challenge getting the furniture put together without those things.

But, having gone through that experience, I can totally sympathize with M.P.'s colleague. Just imagine his frustration when he found out that they forgot to include bitwise operators in his copy of C# ...

public bool IsFileReadOnly(int attributes)
{
  bool retVal = false;

  if (attributes > 63)
  {
    attributes = attributes - 63;
  }

  if (attributes > 32)
  {
    attributes = attributes - 32;
  }

  if (attributes > 16)
  {
    attributes = attributes - 16;
  }

  if (attributes > 8)
  {
    attributes = attributes - 8;
  }

  if (attributes > 4)
  {
    attributes = attributes - 4;
  }

  if (attributes > 2)
  {
    attributes = attributes - 2;
  }

  if (attributes  == 1)
  {
    retVal = true;
  }

  return retVal;
}


public bool IsFileHidden(int attributes)
{
  bool retVal = false;

  if (attributes > 63)
  {
    attributes = attributes - 63;
  }

  if (attributes > 32)
  {
    attributes = attributes - 32;
  }

  if (attributes > 16)
  {
    attributes = attributes - 16;
  }

  if (attributes > 8)
  {
    attributes = attributes - 8;
  }

  if (attributes > 4)
  {
    attributes = attributes - 4;
  }

  if ( (attributes >= 2) && (attributes < 4) )
  {
    retVal = true;
  }

  return retVal;
}


public bool IsFileSysFile(int attributes)
{
  bool retVal = false;

  if (attributes > 63)
  {
    attributes = attributes - 63;
  }

  if (attributes > 32)
  {
    attributes = attributes - 32;
  }

  if (attributes > 16)
  {
    attributes = attributes - 16;
  }

  if (attributes > 8)
  {
    attributes = attributes - 8;
  }

  if ( (attributes >= 4) && (attributes < 8) )
  {
    retVal = true;
  }

  return retVal;
}


public bool IsFileVolumeId(int attributes)
{
  bool retVal = false;

  if (attributes > 63)
  {
    attributes = attributes - 63;
  }

  if (attributes > 32)
  {
    attributes = attributes - 32;
  }

  if (attributes > 16)
  {
    attributes = attributes - 16;
  }

  if ( (attributes >= 8) && (attributes < 16) )
  {
    retVal = true;
  }

  return retVal;
}


public bool IsFileDirectory(int attributes)
{
  bool retVal = false;

  if (attributes > 63)
  {
    attributes = attributes - 63;
  }

  if (attributes > 32)
  {
    attributes = attributes - 32;
  }

  if ( (attributes >= 16) && (attributes < 32) )
  {
    retVal = true;
  }

  return retVal;
}


public bool IsFileArchive(int attributes)
{
  bool retVal = false;

  if (attributes > 63)
  {
    attributes = attributes - 63;
  }

  if ( (attributes >= 32) && (attributes < 63) )
  {
    retVal = true;
  }

  return retVal;
}


public bool IsFileAny(int attributes)
{
  bool retVal = false;

  if (attributes >= 63)
  {
    retVal = true;
  }

  return retVal;
}

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!