Beispiel #1
0
File::File(const ACE_TString& fname_phys, const ACE_TString& logical,
           Directory* parent)
  : physical_file_()
  , physical_dir_()
  , logical_relative_(logical)
  , parent_(parent, false)
{
  String_Index_t last_slash = fname_phys.rfind(ACE_TEXT('/'));

  if (last_slash == ACE_TString::npos) {
    physical_file_ = fname_phys;
    physical_dir_ = ACE_TEXT(".");

  } else {
    physical_file_ = fname_phys.c_str() + last_slash + 1;
    physical_dir_.set(fname_phys.c_str(), last_slash, true);
  }
}
Beispiel #2
0
void
ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
                               ACE_Array<ACE_TString> &try_names)
{
  // Build the array of DLL names to try on this platform by applying the
  // proper prefixes and/or suffixes to the specified dll_name.
  ACE_TString base (dll_name);
  ACE_TString base_dir, base_file, base_suffix;

  // 1. Separate the dll_name into the dir part and the file part. We
  // only decorate the file part to determine the names to try loading.
  ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);
  if (pos != ACE_TString::npos)
    {
      base_dir = base.substr (0, pos + 1);
      base_file = base.substr (pos + 1);
    }
  else
    base_file = base;

  // 2. Locate the file suffix, if there is one. Move the '.' and the
  // suffix to base_suffix.
  if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos)
    {
      base_suffix = base_file.substr (pos);
      base_file = base_file.substr (0, pos);
    }

  // 3. Build the combinations to try for this platform.
  // Try these combinations:
  //   - name with decorator and platform's suffix appended (if not supplied)
  //   - name with platform's suffix appended (if not supplied)
  //   - name with platform's dll prefix (if it has one) and suffix
  //   - name with platform's dll prefix, decorator, and suffix.
  //   - name as originally given
  // We first try to find the file using the decorator so that when a
  // filename with and without decorator is used, we get the file with
  // the same decorator as the ACE dll has and then as last resort
  // the one without. For example with msvc, the debug build has a "d"
  // decorator, but the release build has none and we really want to get
  // the debug version of the library in a debug application instead
  // of the release one.
  // So we need room for 5 entries in try_names.
  try_names.size (0);
  if ((try_names.max_size () - try_names.size ()) < 5)
    try_names.max_size (try_names.max_size () + 5);
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
  ACE_TString decorator (ACE_LD_DECORATOR_STR);
#endif
  ACE_TString suffix (ACE_DLL_SUFFIX);
  ACE_TString prefix (ACE_DLL_PREFIX);

  for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)
    {
      ACE_TString try_this;
      size_t j = try_names.size ();
      switch (i)
        {
        case 0:        // Name + decorator + suffix
        case 1:        // Name + suffix
        case 2:        // Prefix + name + decorator + suffix
        case 3:        // Prefix + name + suffix
          if (
              base_suffix.length () > 0
#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))
              || (i == 1 || i == 3)    // No decorator desired; skip
#endif
              )
            break;
          try_this = base_dir;
          if (i > 1)
            try_this += prefix;
          try_this += base_file;
          if (base_suffix.length () > 0)
            try_this += base_suffix;
          else
            {
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
              try_this += decorator;
#endif
              try_this += suffix;
            }
          break;
        case 4:
          try_this = dll_name;
          break;
        }

      if (try_this.length ())
        {
          try_names.size (j + 1);
          try_names.set (try_this, j);
        }
    }
  return;
}
Beispiel #3
0
void
ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name,
                               ACE_Array<ACE_TString> &try_names)
{
  // Build the array of DLL names to try on this platform by applying the
  // proper prefixes and/or suffixes to the specified dll_name.
  ACE_TString base (dll_name);
  ACE_TString base_dir, base_file, base_suffix;

  // 1. Separate the dll_name into the dir part and the file part. We
  // only decorate the file part to determine the names to try loading.
  int pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR);
  if (pos != ACE_TString::npos)
    {
      base_dir = base.substr (0, static_cast<ssize_t>(pos) + 1);
      base_file = base.substr (static_cast<size_t>(pos) + 1);
    }
  else
    base_file = base;

  // 2. Locate the file suffix, if there is one. Move the '.' and the
  // suffix to base_suffix.
  if ((pos = base_file.rfind (ACE_LIB_TEXT ('.'))) != ACE_TString::npos)
    {
      base_suffix = base_file.substr (static_cast<size_t>(pos));
      base_file = base_file.substr (0, static_cast<ssize_t>(pos));
    }

  // 3. Build the combinations to try for this platform.
  // Try these combinations:
  //   - name as originally given
  //   - name with decorator and platform's suffix appended (if not supplied)
  //   - name with platform's suffix appended (if not supplied)
  //   - name with platform's dll prefix (if it has one) and suffix
  //   - name with platform's dll prefix, decorator, and suffix.
  // So we need room for 5 entries in try_names.
  try_names.size (0);
  if ((try_names.max_size () - try_names.size ()) < 5)
    try_names.max_size (try_names.max_size () + 5);
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
  ACE_TString decorator (ACE_LD_DECORATOR_STR);
#endif
  ACE_TString suffix (ACE_DLL_SUFFIX);
  ACE_TString prefix (ACE_DLL_PREFIX);

  for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i)
    {
      ACE_TString try_this;
      size_t j = try_names.size ();
      switch (i)
        {
        case 0:
          try_this = dll_name;
          break;

        case 1:        // Name + decorator + suffix
        case 2:        // Name + suffix
        case 3:        // Prefix + name + decorator + suffix
        case 4:        // Prefix + name + suffix
          if (
              base_suffix.length () > 0
#if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK))
              || (i == 2 || i == 4)    // No decorator desired; skip
#endif
              )
            break;
          try_this = base_dir;
          if (i > 2)
            try_this += prefix;
          try_this += base_file;
          if (base_suffix.length () > 0)
            try_this += base_suffix;
          else
            {
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
              try_this += decorator;
#endif
              try_this += suffix;
            }
          break;
        }

      if (try_this.length ())
        {
          try_names.size (j + 1);
          try_names.set (try_this, j);
        }
    }
  return;
}
Beispiel #4
0
    int ExtractProperties(const ACE_TString& input, mstrings_t& properties)
    {
        TTASSERT(input.find('\n') == input.rfind('\n'));

        bool bSyntaxError = false;
        if( input.length() == 0 )
            bSyntaxError = true;

        size_t offset = input.find(' ');//past command
        if(offset == ACE_TString::npos)
            return 0;

        while(offset < input.length() && !bSyntaxError)
        {
            //past any spaces
            offset = pastBlanks(offset, input);
            if(offset == input.length())
            {
                break;
            }

            size_t propBegin = offset;
            ACE_TString prop;
            ACE_TString value;
            while(offset < input.length()) //extract property name
            {
                if( input[offset] != ' ' && input[offset] != '=') offset ++;
                else break;
            }
            if(offset == input.length())
            {
                bSyntaxError = true; //no properties in ACE_TString
                break;
            }

            prop = input.substr(propBegin, offset-propBegin); //set propertyname
            TTASSERT(properties.find(prop) == properties.end());
            offset = pastBlanks(offset, input); //past spaces
            if(offset == input.length())
            {
                bSyntaxError = true;
                break;
            }
            if(input[offset] != '=')
            {
                bSyntaxError = true;
                break;
            }
            else offset ++; //past =

            offset = pastBlanks(offset, input); //past spaces
            if(offset == input.length())
            {
                bSyntaxError = true;
                break;
            }

            //determine whether it's a string or an integer
            if(input[offset] == '"') //a ACE_TString
            {
                bool found = false;
                size_t strBegin = ++offset; //past "
                while(!found && offset<input.length())
                {
                    /*
                    if(input[offset]==ACE_TEXT('\"') && input[offset-1] != ACE_TEXT('\\')) found = true;
                    offset++;
                    */
                    if(input[offset] == '\\')
                        offset += 2;
                    else if(input[offset] == '"')
                    {
                        found = true;
                        offset++;
                    }
                    else
                        offset++;
                }

                if(!found)
                {
                    bSyntaxError = true;
                    break;
                }

                value = input.substr(strBegin, offset-strBegin-1);
                offset ++; //past \"

                properties[prop] = RebuildString(value);
                //properties.SetAt(prop, RebuildString(value));
            }
            else if(input[offset] == '[') // an int list
            {
                bool found = false;
                size_t listBegin = ++offset; //past "
                while(!found && offset<input.length())
                {
                    if(input[offset] == ']') found = true;
                    offset++;
                }

                if(!found)
                {
                    bSyntaxError = true;
                    break;
                }

                value = input.substr(listBegin, offset-listBegin-1);
                offset ++; //past ]

                properties[prop] = RebuildString(value);
                //properties.SetAt(prop, RebuildString(value));
            }
            else //eat what's left until space
            {
                size_t intBegin = offset;
                while(offset<input.length() && 
                    input[offset] != ' ' && 
                    input[offset] != '\r' &&
                    input[offset] != '\n') offset ++; //past spaces
                value = input.substr(intBegin, offset-intBegin);

                properties[prop] = RebuildString(value);
                //properties.SetAt(prop, RebuildString(value));
            }
        }

        return bSyntaxError? -1 : (int)properties.size();
    }