DOS批处理中%cd%和%~dp0的区别

在DOS的批处理中,有时候需要知道当前的路径。在DOS中,有两个环境变量可以跟当前路径有关,一个是%cd%, 一个是%~dp0。这两个变量的用法和代表的内容是不同的:
1. %cd% 可以用在批处理文件中,也可以用在命令行中;展开后,是驱动器盘符:+当前目录,如在dos窗口中进入c:dir目录下面, 

输入:echo %cd% ,则显示为:c:dir 。
%cd%的内容是可以被改变的,其内容为命令的执行路径或批处理文件的执行路径。

2.%~dp0只可以用在批处理文件中,它是由它所在的批处理文件的目录位置决定的,是批处理文件所在的盘符:+路径。在执行这个批处理文件的过程中,它展开后的内容是不可以改变的。比如在D盘下有个批处理文件,path.bat,其内容为:

代码如下:
@echo off
echo this is %%cd%% %cd%
echo this is %%~dp0 %~dp0

SAE未备案域名加速

众所周知,SAE对于未备案的域名比较的不仁慈,访问二级域名还好说,但对于大多数绑定顶级域名而又苦于备案的站长来说,不但得不到SAE的高速,反而变得更慢。虽然通过DNSPOD+加速乐/360DNS等免费资源可以实现双DNS加速,以及开启GZIP对网站改良的措施,对网站速度有了一定的改观,但毕竟使用的是海外代理,速度终究不理想。

网站的速度无论从SEO角度还是用户体验方面来说,都是一个网站不可忽视的要素,相信众多站长长期奔走于对此优化的道路上,由此也引出了一些极其优秀的缓存软件,诸如Hyper Cache、W3 Total Cache、Wp Super Cache这些插件在网站的优化上有着极其优秀的表现,然而对于驻扎在SAE上的用户来说,目录写入权限是不可改变的硬伤。所以这些所谓的加速神器也是爱莫能助了,加之SAE的优化方法少之又少,除了压缩和DNS外似乎别无他法。

本人也是经过长期致力于此,最终发现一个好方法,作为福利共享出来-SAE未备案域名加速插件:

这个插件的作用主要是用来加速SAE未备案域名的访问速度,用创新的方法实现加速:采用的策略是将资源文件通过SAE二级域名进行访问,而将网站主要文件通过主域名访问,进而加快了访问速度。这个插件最初是由SAE云商店用于加速wordpress的访问,当然在SAE上也是可以使用的,由于SAE和云商店环境的细微差异,所以在SAE只需要稍加修改即可使用,下面是已经修改的可以在SAE使用的插件源代码。

<?php
if(isset($_SERVER['HTTP_APPNAME'])){
add_filter('pre_option_siteurl','ysd_siteurl');
add_filter('pre_option_home','ysd_home');
add_filter('site_url','ysd_site_url',10,2);
add_filter('login_url','ysd_login_url');
add_filter('logout_url','ysd_logout_url');
add_filter('admin_url','ysd_admin_url');
add_action('wp_before_admin_bar_render','ysd_before_admin_bar_render');
add_action('wp_after_admin_bar_render','ysd_after_admin_bar_render');
}
function ysd_siteurl(){
return 'index.php'==basename($_SERVER['SCRIPT_FILENAME']) && false===strpos($_SERVER['SCRIPT_FILENAME'], 'wp-admin')?'http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com':'http://'.$_SERVER['HTTP_HOST'];
}
function ysd_home(){
return 'http://'.$_SERVER['HTTP_HOST'];
}
function ysd_site_url($url,$path){
if(in_array($path,array('wp-login.php?action=register','/wp-comments-post.php'))){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$url);
}else{
return $url;
}
}
function ysd_before_admin_bar_render(){
ob_start();
}
function ysd_after_admin_bar_render(){
echo str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],ob_get_clean());
}
function ysd_login_url($login_url){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$login_url);
}
function ysd_logout_url($logout_url){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$logout_url);
}
function ysd_admin_url($url){
return str_replace('http://'.substr($_SERVER['HTTP_APPNAME'],5).'.1kapp.com', 'http://'.$_SERVER['HTTP_HOST'],$url);
}
?>

 

 

Welcome to Swift

Welcome to Swift

Swift is a new object-oriented programming language for iOS and OS X development. Swift is modern, powerful, and easy to use.

  • let people = ["Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25]
  • for (name, age) in people {
  • println("(name) is (age) years old.")
  • }

 


The Swift Programming Language

The complete guide and reference to the Swift programming language.

  • Take an interactive tour of language features that make app development easier, faster, and more reliable.

  • Learn Swift concepts, principles, and syntax through comprehensive descriptions and code examples.

  • Dive into the details of the language with a thorough discussion of its behavior, syntax, and grammar.

Using Swift with Cocoa and Objective-C

Tools and strategies for integrating Swift into the Cocoa app development process.

  • Learn how to interact with Cocoa frameworks in a Swift environment.

  • Take advantage of Swift language features to build on Objective-C APIs, and improve the way you write Cocoa apps.

  • Create a mixed-language app using Swift and Objective-C.

  • Explore strategies to migrate your app to Swift.

2025 年 5 月
 1234
567891011
12131415161718
19202122232425
262728293031  

广告

分类

近期评论

标签

历史上的今天

归档