We just use ltdl's implementation for this abstraction now. Its portable to
[oota-llvm.git] / lib / System / Path.cpp
1 //===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Reid Spencer and is distributed under the 
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 //  This header file implements the operating system Path concept.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/System/Path.h"
15 #include <cassert>
16
17 namespace llvm {
18 using namespace sys;
19
20 //===----------------------------------------------------------------------===//
21 //=== WARNING: Implementation here must contain only TRULY operating system
22 //===          independent code. 
23 //===----------------------------------------------------------------------===//
24
25 LLVMFileType 
26 sys::IdentifyFileType(const char*magic, unsigned length) {
27   assert(magic && "Invalid magic number string");
28   assert(length >=4 && "Invalid magic number length");
29   switch (magic[0]) {
30     case 'l':
31       if (magic[1] == 'l' && magic[2] == 'v') {
32         if (magic[3] == 'c')
33           return CompressedBytecodeFileType;
34         else if (magic[3] == 'm')
35           return BytecodeFileType;
36       }
37       break;
38
39     case '!':
40       if (length >= 8) {
41         if (memcmp(magic,"!<arch>\n",8) == 0)
42           return ArchiveFileType;
43       }
44       break;
45
46     default:
47       break;
48   }
49   return UnknownFileType;
50 }
51
52 }
53
54 // Include the truly platform-specific parts of this class.
55 #include "platform/Path.cpp"
56
57 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab